Sends events to a broker.
Sends events to a broker.
(post-events this events)
Posts one or more events
Posts one or more events
Receives events from a broker, either by polling or by registering a listener.
Receives events from a broker, either by polling or by registering a listener.
(add-listener this listener)
Registers a listener to receive incoming events
Registers a listener to receive incoming events
(poll-events this n)
Returns up to n
pending events, using pull model. If n
is nil
, returns all
pending events.
Returns up to `n` pending events, using pull model. If `n` is `nil`, returns all pending events.
(handler->fn handler)
Converts the handler into an invokable function that applies interceptors
Converts the handler into an invokable function that applies interceptors
A listener is returned when adding a listener to a broker. It's usually broker implementation specific and allows to unregister the listener.
A listener is returned when adding a listener to a broker. It's usually broker implementation specific and allows to unregister the listener.
(invoke-listener this evt)
Invokes this listener with the given event
Invokes this listener with the given event
(unregister-listener this)
Unregisters the listener from the event receiver it was previously added to.
Returns true
if it was succesfully unregistered.
Unregisters the listener from the event receiver it was previously added to. Returns `true` if it was succesfully unregistered.
(make-router routes & [{:keys [interceptors] :as opts}])
Creates an event router object. It can be registered as a listener and it will
route events according to the route configuration. The router returns a structure
holding the processed event, the handler, and the handler return value for each
of the matched handlers. If no handlers are found, returns nil
.
An extra options map can be passed in to override default behaviour:
:matcher
: function that determines the handlers to invoke for an event, defaults to type-matcher
.:invoker
: function that performs handler invocation. By default this is the sync-invoker
.:interceptors
: custom interceptors, prepended to the route-specific interceptors.Creates an event router object. It can be registered as a listener and it will route events according to the route configuration. The router returns a structure holding the processed event, the handler, and the handler return value for each of the matched handlers. If no handlers are found, returns `nil`. An extra options map can be passed in to override default behaviour: - `:matcher`: function that determines the handlers to invoke for an event, defaults to `type-matcher`. - `:invoker`: function that performs handler invocation. By default this is the `sync-invoker`. - `:interceptors`: custom interceptors, prepended to the route-specific interceptors.
(poll-next e)
Polls for next event from the receiver
Polls for next event from the receiver
(replace-interceptors router replacements)
Creates a new router with the given interceptors replaced. The interceptors with
the same :name
are replaced by the ones in the replacement collection. This is
useful in tests when you want to 'mock out' certain side-effecting interceptors.
Creates a new router with the given interceptors replaced. The interceptors with the same `:name` are replaced by the ones in the replacement collection. This is useful in tests when you want to 'mock out' certain side-effecting interceptors.
Used by the router to find handlers for an incoming event.
Used by the router to find handlers for an incoming event.
(compile-routes this routes)
Compiles routes in a format that is more suitable for the matcher
Compiles routes in a format that is more suitable for the matcher
(find-handlers this routes evt)
Checks if this matches given event
Checks if this matches given event
(sync-invoker handlers evt)
Handler invoker that invokes each of the handlers in sequence.
Handler invoker that invokes each of the handlers in sequence.
Converts the object into an event handler fn.
Converts the object into an event handler fn.
(->handler this)
Converts this to a handler
Converts this to a handler
Handler matcher that assumes routes is a map and that matches by event type
Handler matcher that assumes routes is a map and that matches by event type
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close