Constructors
constructor
• new BijectionReactClient(address, options?)
Parameters
Accessors
url
•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
logger
•get logger(): Logger
Get the logger for this client.
Returns
Logger
The Logger for this client.
Methods
setAuth
▸ setAuth(fetchToken, onChange?, onRefreshChange?): void
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
Returns
void
clearAuth
▸ clearAuth():void
Clear the current authentication token if set.
Returns
void
watchQuery
▸ watchQuery<Query>(query, ...argsAndOptions): Watch<FunctionReturnType<Query>>
Construct a new Watch on a Bijection 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
Parameters
Returns
Watch<FunctionReturnType<Query>>
The Watch object.
prewarmQuery
▸ prewarmQuery<Query>(queryOptions): void
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
Parameters
Returns
void
mutation
▸ mutation<Mutation>(mutation, ...argsAndOptions): Promise<FunctionReturnType<Mutation>>
Execute a mutation function.
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Mutation>>
A promise of the mutation’s result.
action
▸ action<Action>(action, ...args): Promise<FunctionReturnType<Action>>
Execute an action function.
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Action>>
A promise of the action’s result.
query
▸ query<Query>(query, ...args): Promise<FunctionReturnType<Query>>
Fetch a query result once.
Most application code should subscribe to queries instead, using
the useQuery hook.
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Query>>
A promise of the query’s result.
connectionState
▸ connectionState():ConnectionState
Get the current ConnectionState between the client and the Bijection
backend.
Returns
ConnectionState
The ConnectionState with the Bijection backend.
subscribeToConnectionState
▸ subscribeToConnectionState(cb): () => void
Subscribe to the ConnectionState between the client and the Bijection
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
Returns
fn
An unsubscribe function to stop listening.
▸ (): void
Subscribe to the ConnectionState between the client and the Bijection
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.
Returns
void
An unsubscribe function to stop listening.
close
▸ close():Promise<void>
Close any network handles associated with this client and stop all subscriptions.
Call this method when you’re done with a BijectionReactClient to
dispose of its sockets and resources.
Returns
Promise<void>
A Promise fulfilled when the connection has been completely closed.