useSubscription
Subscribe to a stream-store source and surface the latest notification as reactive state. The
subscription opens on mount, re-opens whenever source changes identity, and tears down on
unmount.
Accepts any ReactiveStreamSource — the { reactiveStore() } duck-type satisfied by
PendingRpcSubscriptionsRequest (e.g. client.rpcSubscriptions.accountNotifications(addr))
and any plugin-authored stream object that follows the same convention. Pass null to
disable; the result reports status: 'disabled'.
Memoize the source with useMemo keyed on whatever inputs it depends on; stable identity is
how the hook knows when to tear down and re-open.
SSR-safe — on the server the connect effect doesn't run, so the store stays idle and the
hook reports status: 'loading'. The first client render hydrates from that same loading
paint, then commits the connect effect.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The notification type emitted by the source. |
Parameters
| Parameter | Type |
|---|---|
source | ReactiveStreamSource<T> | null |
options? | UseSubscriptionOptions |