API reference · generated from source
Read the guide →Class: RetreeConvexReactClient#
Defined in: packages/retree-react-convex/src/index.ts:61
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.
The client also implements Retree's observable auth surface
(IConvexAuthClient) by interposing on setAuth/clearAuth, so a
ConvexAuthStateNode can track isLoading/isAuthenticated reactively.
Extends#
ConvexReactClient
Implements#
IConvexAuthClient
Constructors#
Constructor#
new RetreeConvexReactClient(address, options?): RetreeConvexReactClient;Defined in: packages/retree-react-convex/src/index.ts:74
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.actionauthState()#
authState(): ConvexAuthState;Defined in: packages/retree-react-convex/src/index.ts:86
Get the current authentication state.
Returns#
ConvexAuthState
Remarks#
Before RetreeConvexReactClient.setAuth runs, the client is
unauthenticated and not loading. While a token fetch started by
setAuth awaits server confirmation, isLoading is true.
Implementation of#
IConvexAuthClient.authStateclearAuth()#
clearAuth(): void;Defined in: packages/retree-react-convex/src/index.ts:131
Clear the current authentication token, resetting the observable auth state to unauthenticated.
Returns#
void
Overrides#
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:167
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:152
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: packages/retree-react-convex/src/index.ts:109
Set the authentication token fetcher, tracking the resulting auth state so ConvexAuthStateNode subscribers stay current.
Parameters#
| Parameter | Type |
|---|---|
fetchToken | AuthTokenFetcher |
onChange? | (isAuthenticated) => void |
onRefreshChange? | (isRefreshing) => void |
Returns#
void
Overrides#
ConvexReactClient.setAuthsubscribeToAuthState()#
subscribeToAuthState(callback): () => void;Defined in: packages/retree-react-convex/src/index.ts:96
Subscribe to authentication state changes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
callback | (authState) => void | Called whenever isLoading or isAuthenticated change. |
Returns#
Function that removes the listener.
() => void
Implementation of#
IConvexAuthClient.subscribeToAuthStatesubscribeToConnectionState()#
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