Skip to content

Commit

Permalink
Merge pull request #4 from get-convex/pass-options
Browse files Browse the repository at this point in the history
Options for client
  • Loading branch information
thomasballinger authored Jun 11, 2024
2 parents 6ac720e + 10bfea0 commit da14984
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.11.2.
* Generated by convex@1.12.1.
* To regenerate, run `npx convex dev`.
* @module
*/
Expand Down
2 changes: 1 addition & 1 deletion src/convex/_generated/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.11.2.
* Generated by convex@1.12.1.
* To regenerate, run `npx convex dev`.
* @module
*/
Expand Down
2 changes: 1 addition & 1 deletion src/convex/_generated/dataModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.11.2.
* Generated by convex@1.12.1.
* To regenerate, run `npx convex dev`.
* @module
*/
Expand Down
2 changes: 1 addition & 1 deletion src/convex/_generated/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.11.2.
* Generated by convex@1.12.1.
* To regenerate, run `npx convex dev`.
* @module
*/
Expand Down
2 changes: 1 addition & 1 deletion src/convex/_generated/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@1.11.2.
* Generated by convex@1.12.1.
* To regenerate, run `npx convex dev`.
* @module
*/
Expand Down
7 changes: 4 additions & 3 deletions src/lib/client.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getContext, setContext, untrack } from 'svelte';
import { ConvexClient } from 'convex/browser';
import { ConvexClient, type ConvexClientOptions } from 'convex/browser';
import {
type FunctionReference,
type FunctionArgs,
Expand All @@ -25,12 +25,13 @@ export const setConvexClientContext = (client: ConvexClient): void => {
setContext(_contextKey, client);
};

export const setupConvex = (url: string) => {
export const setupConvex = (url: string, options?: ConvexClientOptions = {}) => {
if (!url || typeof url !== 'string') {
throw new Error('Expected string url property for setupConvex');
}
const optionsWithDefaults = { disabled: !BROWSER, ...options };

const client = new ConvexClient(url, { disabled: !BROWSER });
const client = new ConvexClient(url, optionsWithDefaults);
setConvexClientContext(client);
$effect(() => () => client.close());
};
Expand Down

0 comments on commit da14984

Please sign in to comment.