createAsyncGeneratorWithInitialValueAndSlotTracking
Creates an async generator that combines an initial RPC fetch with an ongoing subscription, yielding values as they arrive from either source.
The generator uses slot-based comparison to ensure that only the most recent values are yielded. Any value at a slot older than a previously yielded value is silently dropped. This prevents stale data from appearing when the RPC response and subscription notifications arrive out of order.
Things to note:
- The generator yields SolanaRpcResponse values from both the RPC response and subscription notifications, each containing the slot context and the mapped value.
- Out-of-order values (by slot) are silently dropped — they are never yielded.
- On error from either source, the generator throws the error.
- Triggering the caller's abort signal causes the generator to return (complete without error).
- The generator completes when the subscription ends, an error occurs, or the abort signal fires.
Type Parameters
| Type Parameter |
|---|
TRpcValue |
TSubscriptionValue |
TItem |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | CreateAsyncGeneratorWithInitialValueAndSlotTrackingConfig<TRpcValue, TSubscriptionValue, TItem> | - |
Returns
AsyncGenerator<Readonly<{
context: Readonly<{
slot: Slot;
}>;
value: TItem;
}>>