API reference > @kontsedal/olas-realtime > onReconnect
onReconnect() function
Trigger fn() when the realtime connection transitions back to'connected' from a non-connected state. Typical use: invalidate queries that may have missed updates during the disconnect window.
The handler fires AFTER the transition is observed; it does NOT fire on the initial 'connected' value (no transition happened yet). Wrapped in untracked so cache writes don't accidentally hook the effect.
A resume that moves the state from 'offline' or 'reconnecting' back to'connected' counts: createConnectionState restarts at the transport's latest report, or at 'connected' when there is none. The controller's own channel subscriptions stopped while it was suspended, so the refetch is due either way.
Signature:
export declare function onReconnect(ctx: Ctx<RealtimeDeps>, fn: () => void): void;Parameters
Parameter | Type | Description |
|---|---|---|
ctx | ||
fn | () => void |
Returns:
void