API reference · generated from source
Interface: IQuerySubscriptionSource<TArgs, TValue>#
Defined in: retree-query/src/types.ts:39
Minimal backend surface a QueryNode subscribes through.
Remarks#
Implement this to drive a QueryNode from any async backend: a realtime sync client, a fetch poller, a WebSocket topic, and so on. The source is subscribed when the node gains its first Retree observer and unsubscribed when it loses its last one.
subscribe may surface a synchronously cached error by calling onError
from inside getCurrentValue(); the node keeps that error visible instead
of resetting to pending.
Type Parameters#
| Type Parameter |
|---|
TArgs |
TValue |
Methods#
subscribe()#
subscribe(
args,
onValue,
onError): IQuerySubscriptionHandle<TValue>;Defined in: retree-query/src/types.ts:48
Open a subscription for the given arguments.
Parameters#
| Parameter | Type | Description |
|---|---|---|
args | TArgs | Query arguments. |
onValue | (value) => void | Called when the backend emits a new query value. |
onError | (error) => void | Called when the backend emits a subscription error. |
Returns#
IQuerySubscriptionHandle<TValue>
Handle used to read cached values and stop the subscription.