ReactiveStore
A reactive store that holds the latest value published to a data channel and allows external
systems to subscribe to changes. Compatible with useSyncExternalStore, Svelte stores, Solid's
from(), and other reactive primitives that expect a { subscribe, getState } contract.
Example
See
createReactiveStoreFromDataPublisher
Type Parameters
| Type Parameter |
|---|
T |
Methods
getError()
Returns the error published to the error channel, or undefined if no error has occurred.
Once set, the error is preserved — subsequent errors do not overwrite it.
Returns
unknown
getState()
Returns the most recent value published to the data channel, or undefined if no
notification has arrived yet. On error, continues to return the last known value.
Returns
T | undefined
subscribe()
Registers a callback to be called whenever the state changes or an error is received. Returns an unsubscribe function. Safe to call multiple times.
Parameters
| Parameter | Type |
|---|---|
callback | () => void |
Returns
Returns
void