polix.triggers.registry
Trigger registration and lookup.
Provides functions for managing trigger lifecycle: registration, unregistration, and querying. The registry maintains an index by event type for efficient lookup during event processing.
See polix.triggers.core for the public API.
create-registry
(create-registry)Creates an empty trigger registry.
The registry contains a map of triggers keyed by ID and an index mapping event types to sets of trigger IDs for O(1) lookup.
get-trigger
(get-trigger registry trigger-id)Returns a trigger by ID, or nil if not found.
get-triggers
(get-triggers registry)Returns all registered triggers as a sequence.
get-triggers-for-event
(get-triggers-for-event registry event-type)Returns triggers that listen for the given event type.
Triggers are sorted by priority (lower values fire first). Returns an empty sequence if no triggers match the event type.
register-trigger
(register-trigger registry trigger-def source-id owner self)Registers a trigger definition in the registry.
Takes a trigger definition map and binding context. The trigger receives a unique ID and is stored with its source, owner, and self bindings. Returns the updated registry.
unregister-trigger
(unregister-trigger registry trigger-id)Removes a trigger by ID from the registry.
Returns the updated registry. If the trigger ID does not exist, returns the registry unchanged.
unregister-triggers-by-source
(unregister-triggers-by-source registry source-id)Removes all triggers registered by a source.
Useful when an ability or effect is removed and all its triggers should be cleaned up. Returns the updated registry.