Skip to main content
Pass a NexusStreamObserver via Config.streamObserver to receive structured callbacks for every SSE lifecycle transition. The observer is the canonical way to wire SDK state into ops dashboards, custom telemetry, or load-test tooling - far more reliable than scraping Logger output by substring match. The observer is opt-in. When Config.streamObserver is undefined the SDK uses NOOP_STREAM_OBSERVER at zero overhead.

The interface

Every method is optional - the SDK calls only the ones you set. You can write { onEvent: (n) => count(n) } and ignore the rest.

Hook semantics

onFallback reasons

Angular zone integration

Observer methods are called inside NgZone.run(...) automatically - the same wrapping the SDK already uses for its stream event handlers. This means:
  • Signals updated inside an observer method trigger change detection
  • Component reads inside an observer method see the latest state
  • You do NOT need to wrap the observer body manually

Threading contract

Observer methods MUST return promptly. The SDK calls them synchronously from the stream reader loop (after the NgZone.run(...) wrap). If your observer does anything substantial (network I/O, structured logging fan-out), copy the argument and dispatch the work to a future microtask.

Counter pattern

Active-connection signal pattern

Maintain a “live” indicator backed by an Angular signal:
Then in a template: