Constructors
constructor
• new BaseBijectionClient(address, onTransition, 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
Methods
getMaxObservedTimestamp
▸ getMaxObservedTimestamp():undefined | Long
Returns
undefined | Long
addOnTransitionHandler
▸ addOnTransitionHandler(fn): () => boolean
Add a handler that will be called on a transition.
Any external side effects (e.g. setting React state) should be handled here.
Parameters
Returns
fn
▸ (): boolean
Returns
boolean
getCurrentAuthClaims
▸ getCurrentAuthClaims():undefined | { token: string ; decoded: Record<string, any> }
Get the current JWT auth token and decoded claims.
Returns
undefined | { token: string ; decoded: Record<string, any> }
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
hasAuth
▸ hasAuth():boolean
Returns
boolean
clearAuth
▸ clearAuth():void
Returns
void
subscribe
▸ subscribe(name, args?, options?): Object
Subscribe to a query function.
Whenever this query’s result changes, the onTransition callback
passed into the constructor will be called.
Parameters
Returns
Object
An object containing a QueryToken corresponding to this
query and an unsubscribe callback.
localQueryResult
▸ localQueryResult(udfPath, args?): undefined | Value
A query result based only on the current, local state.
The only way this will return a value is if we’re already subscribed to the
query or its value has been set optimistically.
Parameters
Returns
undefined | Value
queryJournal
▸ queryJournal(name, args?): undefined | QueryJournal
Retrieve the current QueryJournal for this query function.
If we have not yet received a result for this query, this will be undefined.
Parameters
Returns
undefined | QueryJournal
The query’s QueryJournal or undefined.
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.
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.
Returns
void
An unsubscribe function to stop listening.
mutation
▸ mutation(name, args?, options?): Promise<any>
Execute a mutation function.
Parameters
Returns
Promise<any>
- A promise of the mutation’s result.
action
▸ action(name, args?): Promise<any>
Execute an action function.
Parameters
Returns
Promise<any>
A promise of the action’s result.
close
▸ close():Promise<void>
Close any network handles associated with this client and stop all subscriptions.
Call this method when you’re done with an BaseBijectionClient to
dispose of its sockets and resources.
Returns
Promise<void>
A Promise fulfilled when the connection has been completely closed.