Event emitter: fan-out delivery to registered handlers with a ring buffer.
Handlers registered with :all receive every event regardless of type. Handlers registered with a specific keyword receive only that event type. Handler errors are caught, counted in :dropped stats, and never propagate.
Thread safety: all mutable state lives in atoms updated with swap!/reset!. emit! and handler registration are safe to call concurrently.
Event emitter: fan-out delivery to registered handlers with a ring buffer. Handlers registered with :all receive every event regardless of type. Handlers registered with a specific keyword receive only that event type. Handler errors are caught, counted in :dropped stats, and never propagate. Thread safety: all mutable state lives in atoms updated with swap!/reset!. emit! and handler registration are safe to call concurrently.
(collecting-emitter)Returns an emitter that buffers every event without dropping. Useful in tests: call events to retrieve what was emitted.
Returns an emitter that buffers every event without dropping. Useful in tests: call events to retrieve what was emitted.
(create-emitter)(create-emitter config)Creates an event emitter from an events config map. config keys: :enabled (boolean), :buffer-size (pos-int).
Creates an event emitter from an events config map. config keys: :enabled (boolean), :buffer-size (pos-int).
(emit! emitter event-type data)Emits an event of event-type with data map. Delivers to all :all handlers then all handlers registered for event-type. Exceptions thrown by handlers are caught and counted as :dropped. Returns nil.
Emits an event of event-type with data map. Delivers to all :all handlers then all handlers registered for event-type. Exceptions thrown by handlers are caught and counted as :dropped. Returns nil.
(enabled? emitter)Returns true if the emitter will route events to handlers.
Returns true if the emitter will route events to handlers.
(events emitter)Returns a snapshot of buffered events in emission order (oldest first).
Returns a snapshot of buffered events in emission order (oldest first).
(noop-emitter)Returns a disabled emitter. All emit! calls and handler registrations are no-ops. Use in tests or when monitoring is turned off in config.
Returns a disabled emitter. All emit! calls and handler registrations are no-ops. Use in tests or when monitoring is turned off in config.
(off emitter handler-id)Removes the handler identified by handler-id from emitter. Returns nil.
Removes the handler identified by handler-id from emitter. Returns nil.
(on emitter event-type handler-fn)Registers handler-fn to receive events of event-type. Pass :all to receive every event regardless of type. Returns a handler-id (UUID) that can be passed to off to deregister. Returns nil when the emitter is disabled.
Registers handler-fn to receive events of event-type. Pass :all to receive every event regardless of type. Returns a handler-id (UUID) that can be passed to off to deregister. Returns nil when the emitter is disabled.
(stats emitter)Returns a snapshot of emitter operational metrics. Keys: :emitted (total events emitted), :dropped (handler errors caught).
Returns a snapshot of emitter operational metrics. Keys: :emitted (total events emitted), :dropped (handler errors caught).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |