PendingRpcSubscriptionsRequest
Pending subscriptions are the result of calling a supported method on a RpcSubscriptions object. They encapsulate all of the information necessary to make the subscription without actually making it.
Calling the `subscribe(options)` method on a
PendingRpcSubscriptionsRequest<TNotification> will
trigger the subscription and return a promise for an async iterable that vends TNotifications.
Calling the `reactive(options)` method will
trigger the subscription and return a promise for a ReactiveStore compatible with
useSyncExternalStore, Svelte stores, and other reactive primitives.
Type Parameters
| Type Parameter |
|---|
TNotification |
Methods
reactive()
Triggers the subscription and returns a promise for a ReactiveStore that holds the
latest notification. Compatible with useSyncExternalStore and other reactive primitives
that expect a { subscribe, getState } contract.
Parameters
| Parameter | Type |
|---|---|
options | RpcSubscribeOptions |
Returns
Promise<ReactiveStore<TNotification>>
Example
subscribe()
Triggers the subscription and returns a promise for an async iterable of notifications.
Use for await...of to consume notifications as they arrive. Abort the signal to
unsubscribe.
Parameters
| Parameter | Type |
|---|---|
options | RpcSubscribeOptions |
Returns
Promise<AsyncIterable<TNotification, any, any>>