surfaces.observer

Observer Mixin

Provides a reusable subscribe/notify observer pattern. Surfaces use this to propagate material-change events to downstream surfaces.

deepcopy contract: _subscribers is cleared on copy. The new object starts with no subscribers. SurfaceGroup._rewire_observers() re-establishes subscriptions after any deepcopy of a SurfaceGroup.

Kramer Harrison, 2026

Classes

ObserverMixin()

Mixin providing subscribe/notify observer pattern.

class ObserverMixin[source]

Mixin providing subscribe/notify observer pattern.

Classes inheriting from this mixin gain:
  • subscribe(callback) — register a callback

  • unsubscribe(callback) — deregister a callback

  • _notify() — call all live subscribers

deepcopy contract: _subscribers is cleared on copy. The owning container (e.g. SurfaceGroup) is responsible for re-wiring subscriptions after copy via _rewire_observers().

subscribe(callback: Callable) None[source]

Register a callback to be called when this object changes.

Parameters:

callback – Zero-argument callable to invoke on change.

unsubscribe(callback: Callable) None[source]

Remove a previously registered callback.

Parameters:

callback – The callable to remove. No-op if not registered.