Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options for client #4

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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