createReactiveStoreWithInitialValueAndSlotTracking
Creates a ReactiveStreamStore that combines an initial one-shot fetch with an ongoing stream to keep its state up to date.
The store uses slot-based comparison to ensure that only the most recent value is kept, regardless of whether it came from the initial value source or a stream notification. This prevents stale data from overwriting newer data when the two sources arrive out of order.
The two sources are consumed via their `reactiveStore()`
methods rather than by calling send() / subscribe() directly, so any object satisfying the
ReactiveActionSource / ReactiveStreamSource duck-types works — including
PendingRpcRequest / PendingRpcSubscriptionsRequest and plugin-authored wrappers.
Things to note:
- The returned store starts in
status: 'idle'. Call `connect()` to dispatch the initial-value source and open the stream. - The store transitions through
loadinguntil the first value or notification arrives, then toloadedwith a SolanaRpcResponse containing the value and the slot context at which it was observed. - On error from either source, the store transitions to
status: 'error'preserving the last known value. Only the first error per connection window is captured. - A subsequent
connect()aborts the current connection, transitions back tostatus: 'loading'(preserving the last knowndataanderrorfor stale-while-revalidate), and re-builds both inner stores with a fresh inner abort signal. - `reset()` aborts the current connection and returns the
store to
idle, clearingdataanderror. - Attach a caller-provided cancellation source via
`withSignal()` —
store.withSignal(signal).connect()composes the signal with the per-connection controller. Aborting the caller's signal transitions the store toerrorwith that abort reason.
Type Parameters
| Type Parameter |
|---|
TInitialValue |
TStreamValue |
TItem |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<TInitialValue, TStreamValue, TItem> | - |
Returns
ReactiveStreamStore<Readonly<{
context: Readonly<{
slot: Slot;
}>;
value: TItem;
}>>