Skip to main content
NexusObserver is an interface with default no-op implementations for every method. You only need to override the callbacks you care about.
Pass your implementation via NexusConfig.observer. The default is NoopNexusObserver, which discards all events.

Callback reference

onConnected

When it fires: The SSE connection to /v1/stream was established successfully and the SDK received HTTP 200. streamStatus transitions to CONNECTED before this callback is invoked.

onDisconnected

When it fires: The SSE connection was lost. cause is the exception that triggered the disconnect, or null if the disconnect was clean (server closed the stream or disconnectStream() was called). Also fires on a plain 429 rate-limit before the retry delay.

onEvent

When it fires: The SSE stream received a named event from the server (for example config_updated, flag_toggled). The SDK has already started a background sync() call by the time this callback fires. Note: auth_expiring is handled internally and never surfaced here.

onReconnectAttempt

When it fires: A transient failure occurred and the SDK is about to attempt reconnection. attempt is 1-indexed (first reconnect = 1). Called after the back-off delay has elapsed, immediately before the new connection attempt.

onFallback

When it fires: The stream loop has given up after 3 consecutive failures and will no longer attempt to reconnect. TTL-based background sync continues to run.

onQuarantined

When it fires: The server returned HTTP 429 with a quarantine payload ({"error":"quarantined",...}). This happens on both the sync path and the stream path. The SDK automatically pauses until expiresAt before retrying.
A quarantine is a cooperative pause, not a failure. The SDK’s internal failure counter is not incremented when a quarantine occurs.

onBillingOverdue

When it fires: The sync endpoint returned HTTP 402. The tenant has overdue invoices and the server is refusing to serve fresh data. The SDK sets an internal billing-overdue flag that suppresses further sync attempts. Getters continue to return the last successfully cached values.

Full observer example