Skip to content

Prevent initial fetch in onUpdate #111

@Tyler-Petrov

Description

@Tyler-Petrov

When calling the onUpdate method of the ConvexClient I'd like to see an options parameter where I could specify lazy as true. When lazy is true the initial data fetch wouldn't happen.

When options: {lazy: true} is speficied here...

onUpdate<Query extends FunctionReference<"query">>(
query: Query,
args: FunctionArgs<Query>,
callback: (result: FunctionReturnType<Query>) => unknown,
onError?: (e: Error) => unknown,
): Unsubscribe<Query["_returnType"]> {

...this this code doesn't run
// If the callback is registered for a query with a result immediately available
// schedule a fake transition to call the callback soon instead of waiting for
// a new server update (which could take seconds or days).
if (
this.queryResultReady(queryToken) &&
this.callNewListenersWithCurrentValuesTimer === undefined
) {
this.callNewListenersWithCurrentValuesTimer = setTimeout(
() => this.callNewListenersWithCurrentValues(),
0,
);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions