Retree - v1.0.0
    Preparing search index...

    Convex React client adapted to Retree's Convex client interface.

    Use this client anywhere you would normally create a ConvexReactClient, including ConvexProvider. Pass the same instance to Retree BaseConvexNode/ConvexNode classes so Retree query nodes share Convex's React cache and clean up subscriptions through Retree observation.

    Hierarchy

    • ConvexReactClient
      • RetreeConvexReactClient
    Index

    Constructors

    Accessors

    • get logger(): Logger

      Get the logger for this client.

      Returns Logger

      The Logger for this client.

    • get url(): string

      Return the address for this client, useful for creating a new client.

      Not guaranteed to match the address with which this client was constructed: it may be canonicalized.

      Returns string

    Methods

    • Execute an action function.

      Type Parameters

      • Action extends FunctionReference<"action">

      Parameters

      • action: Action

        A server.FunctionReference for the public action to run.

      • ...args: OptionalRestArgs<Action>

        An arguments object for the action. If this is omitted, the arguments will be {}.

      Returns Promise<FunctionReturnType<Action>>

      A promise of the action's result.

    • Clear the current authentication token if set.

      Returns void

    • Close any network handles associated with this client and stop all subscriptions.

      Call this method when you're done with a ConvexReactClient to dispose of its sockets and resources.

      Returns Promise<void>

      A Promise fulfilled when the connection has been completely closed.

    • Get the current ConnectionState between the client and the Convex backend.

      Returns ConnectionState

      The ConnectionState with the Convex backend.

    • Execute a mutation function.

      Type Parameters

      • Mutation extends FunctionReference<"mutation">

      Parameters

      Returns Promise<FunctionReturnType<Mutation>>

      A promise of the mutation's result.

    • Indicates likely future interest in a query subscription.

      The implementation currently immediately subscribes to a query. In the future this method may prioritize some queries over others, fetch the query result without subscribing, or do nothing in slow network connections or high load scenarios.

      To use this in a React component, call useQuery() and ignore the return value.

      Type Parameters

      • Query extends FunctionReference<"query">

      Parameters

      • queryOptions: QueryOptions<Query> & { extendSubscriptionFor?: number }

        A query (function reference from an api object) and its args, plus an optional extendSubscriptionFor for how long to subscribe to the query.

      Returns void

    • Fetch a query result once.

      Most application code should subscribe to queries instead, using the useQuery hook.

      Type Parameters

      • Query extends FunctionReference<"query">

      Parameters

      • query: Query

        A server.FunctionReference for the public query to run.

      • ...args: OptionalRestArgs<Query>

        An arguments object for the query. If this is omitted, the arguments will be {}.

      Returns Promise<FunctionReturnType<Query>>

      A promise of the query's result.

    • Set the authentication token to be used for subsequent queries and mutations. fetchToken will be called automatically again if a token expires. fetchToken should return null if the token cannot be retrieved, for example when the user's rights were permanently revoked.

      Parameters

      • fetchToken: AuthTokenFetcher

        an async function returning the JWT-encoded OpenID Connect Identity Token

      • OptionalonChange: (isAuthenticated: boolean) => void

        a callback that will be called when the authentication status changes

      • OptionalonRefreshChange: (isRefreshing: boolean) => void

        a callback called with true when the socket is paused to fetch a replacement token after a server rejection, and false when refresh completes

      Returns void

    • Subscribe to the ConnectionState between the client and the Convex backend, calling a callback each time it changes.

      Subscribed callbacks will be called when any part of ConnectionState changes. ConnectionState may grow in future versions (e.g. to provide a array of inflight requests) in which case callbacks would be called more frequently. ConnectionState may also lose properties in future versions as we figure out what information is most useful. As such this API is considered unstable.

      Parameters

      • cb: (connectionState: ConnectionState) => void

      Returns () => void

      An unsubscribe function to stop listening.

    • Construct a new Watch on a Convex query function.

      Most application code should not call this method directly. Instead use the useQuery hook.

      The act of creating a watch does nothing, a Watch is stateless.

      Type Parameters

      • Query extends FunctionReference<"query">

      Parameters

      • query: Query

        A server.FunctionReference for the public query to run.

      • ...argsAndOptions: ArgsAndOptions<Query, WatchQueryOptions>

      Returns Watch<FunctionReturnType<Query>>

      The Watch object.