API reference · generated from source
Read the guide →Class: RetreeConvexReactClient#
Defined in: packages/retree-react-convex/src/index.ts:49
Convex React client adapted to Retree's Convex client interface.
Remarks#
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.
Extends#
ConvexReactClient
Constructors#
Constructor#
new RetreeConvexReactClient(address, options?): RetreeConvexReactClient;Defined in: packages/retree-react-convex/src/index.ts:52
Parameters#
| Parameter | Type |
|---|---|
address | string |
options? | ConvexReactClientOptions |
Returns#
RetreeConvexReactClient
Overrides#
ConvexReactClient.constructorAccessors#
logger#
Get Signature#
get logger(): Logger;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:299
Get the logger for this client.
Returns
Logger
The Logger for this client.
Inherited from#
ConvexReactClient.loggerurl#
Get Signature#
get url(): string;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:194
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
Inherited from#
ConvexReactClient.urlMethods#
action()#
action<Action>(action, ...args): Promise<FunctionReturnType<Action>>;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:260
Execute an action function.
Type Parameters#
| Type Parameter |
|---|
Action extends FunctionReference<"action"> |
Parameters#
| Parameter | Type | Description |
|---|---|---|
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.
Inherited from#
ConvexReactClient.actionclearAuth()#
clearAuth(): void;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:208
Clear the current authentication token if set.
Returns#
void
Inherited from#
ConvexReactClient.clearAuthclose()#
close(): Promise<void>;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:308
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.
Inherited from#
ConvexReactClient.closeconnectionState()#
connectionState(): ConnectionState;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:280
Get the current ConnectionState between the client and the Convex backend.
Returns#
ConnectionState
The ConnectionState with the Convex backend.
Inherited from#
ConvexReactClient.connectionStatemutation()#
mutation<Mutation>(mutation, ...argsAndOptions): Promise<FunctionReturnType<Mutation>>;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:250
Execute a mutation function.
Type Parameters#
| Type Parameter |
|---|
Mutation extends FunctionReference<"mutation"> |
Parameters#
| Parameter | Type | Description |
|---|---|---|
mutation | Mutation | A server.FunctionReference for the public mutation to run. |
...argsAndOptions | ArgsAndOptions<Mutation, MutationOptions<FunctionArgs<Mutation>>> | - |
Returns#
Promise<FunctionReturnType<Mutation>>
A promise of the mutation's result.
Inherited from#
ConvexReactClient.mutationonPaginatedUpdate_experimental()#
onPaginatedUpdate_experimental<Query>(
query,
args,
options,
callback,
onError?): IConvexQuerySubscription<
| RetreePaginatedQueryResult<PaginatedQueryItem<Query>>
| undefined>;Defined in: packages/retree-react-convex/src/index.ts:71
Type Parameters#
| Type Parameter |
|---|
Query extends PaginatedQueryReference |
Parameters#
| Parameter | Type |
|---|---|
query | Query |
args | PaginatedQueryArgs<Query> |
options | { initialNumItems: number; } |
options.initialNumItems | number |
callback | (result) => unknown |
onError? | (error) => unknown |
Returns#
IConvexQuerySubscription<
| RetreePaginatedQueryResult<PaginatedQueryItem<Query>>
| undefined>
onUpdate()#
onUpdate<Query>(
query,
args,
callback,
onError?): IConvexQuerySubscription<FunctionReturnType<Query>>;Defined in: packages/retree-react-convex/src/index.ts:56
Type Parameters#
| Type Parameter |
|---|
Query extends QueryReference |
Parameters#
| Parameter | Type |
|---|---|
query | Query |
args | FunctionArgs<Query> |
callback | (result) => unknown |
onError? | (error) => unknown |
Returns#
IConvexQuerySubscription<FunctionReturnType<Query>>
prewarmQuery()#
prewarmQuery<Query>(queryOptions): void;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:237
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#
| Type Parameter |
|---|
Query extends FunctionReference<"query"> |
Parameters#
| Parameter | Type | Description |
|---|---|---|
queryOptions | QueryOptions<Query> & object | 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
Inherited from#
ConvexReactClient.prewarmQueryquery()#
query<Query>(query, ...args): Promise<FunctionReturnType<Query>>;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:273
Fetch a query result once.
Most application code should subscribe to queries instead, using the useQuery hook.
Type Parameters#
| Type Parameter |
|---|
Query extends FunctionReference<"query"> |
Parameters#
| Parameter | Type | Description |
|---|---|---|
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.
Inherited from#
ConvexReactClient.querysetAuth()#
setAuth(
fetchToken,
onChange?,
onRefreshChange?): void;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:204
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#
| Parameter | Type | Description |
|---|---|---|
fetchToken | AuthTokenFetcher | an async function returning the JWT-encoded OpenID Connect Identity Token |
onChange? | (isAuthenticated) => void | a callback that will be called when the authentication status changes |
onRefreshChange? | (isRefreshing) => 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
Inherited from#
ConvexReactClient.setAuthsubscribeToConnectionState()#
subscribeToConnectionState(cb): () => void;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:293
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#
| Parameter | Type |
|---|---|
cb | (connectionState) => void |
Returns#
An unsubscribe function to stop listening.
() => void
Inherited from#
ConvexReactClient.subscribeToConnectionStatewatchQuery()#
watchQuery<Query>(query, ...argsAndOptions): Watch<FunctionReturnType<Query>>;Defined in: node_modules/convex/dist/esm-types/react/client.d.ts:224
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#
| Type Parameter |
|---|
Query extends FunctionReference<"query"> |
Parameters#
| Parameter | Type | Description |
|---|---|---|
query | Query | A server.FunctionReference for the public query to run. |
...argsAndOptions | ArgsAndOptions<Query, WatchQueryOptions> | - |
Returns#
Watch<FunctionReturnType<Query>>
The Watch object.
Inherited from#
ConvexReactClient.watchQuery