actorx/safe_observer

Safe Observer - Observer wrapper that enforces Rx grammar

The safe_observer wraps a downstream observer and:

  1. Enforces Rx grammar: OnNext* (OnError | OnCompleted)?
  2. Disposes resources on terminal events
  3. Ignores messages after terminal event

Note: For full actor-based implementation with message serialization, use gleam_otp actors. This module provides a simpler synchronous version.

Values

pub fn from_notify(
  notify: fn(types.Notification(a)) -> Nil,
  disposable: types.Disposable,
) -> types.Observer(a)

Create an observer from a notification handler function, wrapped with Rx grammar enforcement.

pub fn wrap(
  observer: types.Observer(a),
  disposable: types.Disposable,
) -> types.Observer(a)

Wrap an observer with Rx grammar enforcement.

Returns an Observer that:

  • Forwards OnNext until a terminal event
  • Calls disposal on terminal events
  • Ignores all events after terminal
Search Document