Const Wait for an event OR get the current state if the event already happened This prevents race conditions where events fire before subscription
The event type to wait for
Options for state fetching and transformation
Promise that resolves with either the event data or current state
Subscribe to events with initial state, ensuring no events are missed
The event type to subscribe to
Callback for state updates
Options for initial state fetching
Unsubscribe function
Create a state-synchronized event stream that combines initial state with events
The event type for updates
API endpoint or function to fetch current state
Object with subscribe method and current state getter
Get current state synchronously (may be undefined if not loaded)
Subscribe to state changes (includes initial state)
Wait for multiple events with shared state checking Checks global state once to see if all conditions are already met
Array of event types to wait for
Shared state checking options
Promise that resolves when all events have occurred or state is ready
Wait for a single event with state checking (convenience overload)
Single event type to wait for
State checking options
Promise that resolves when event occurs or state is ready
Create a resilient event handler that can recover from missed events
Event type to handle
Event handler function
Strategy for recovering missed events
Create a connection state manager that handles online/offline scenarios
Export namespace for easier access