Skip to main content

Module events

Module events 

Source
Expand description

Mem-change events: runtime-agnostic callback-based subscribe API.

Every successful write mutation (memstead_create, memstead_update, memstead_delete, memstead_relate, memstead_rename) emits a MemChangedEvent after update-ref lands. Consumers register a callback per mem via [Engine::subscribe_mem_changes] and receive an event on every commit.

The Core (this module + the Engine wiring) is std-only: no tokio, no notify, no async runtime dependency. Tokio-broadcast and filesystem-watcher conveniences live behind opt-in feature flags (tokio, file-watcher) so UniFFI / WASM / sync consumers are not forced to drag async runtimes into their dependency graph.

Consumer-side contract: transport / routing / filtering are not the engine’s job — it only emits the events.

Structs§

MemChangedEvent
Event payload emitted on every committed mutation.
SubscriptionHandle
RAII handle returned by [Engine::subscribe_mem_changes]. Holds the consumer’s subscription id and a back-reference to the engine’s shared registry. On Drop (or via the explicit Self::unsubscribe consumer) the slot is removed from the registry — subsequent events to that mem skip the callback.

Constants§

DEFAULT_BROADCAST_CAPACITY
Default capacity for the tokio broadcast channel returned by [Engine::subscribe_mem_changes_broadcast]. Sized so a typical burst (one mutation per few ms; subscriber polling at frame / HTTP-request granularity) does not trip the lagged-error path, while keeping memory bounded for many subscribers.

Type Aliases§

EventCallback
Type alias for the callback shape consumers register. Arc<dyn Fn> keeps the subscriber’s closure cheaply cloneable so the emit path can snapshot the list, release the registry lock, and call into callbacks without re-entering the engine’s mutex.