(wrap-store store event-fn-in event-fn-out)Wraps the given IEventStore by piping all of the events going in through
event-fn-in and the ones coming out through event-fn-out. The callbacks
are functions of one argument which expect and event and produce an event,
several events or no events (nil or empty seq) synchronously.
event-fn-in can only produce a single event when given an event.
If the middleware returns multiple events in place of a single one, the
functions of EventStore will work as follows:
read-event will return whatever event-fn-out returnsread-stream-* concatenates the events produced by event-fn-outExample:
(defn log [store] (wrap-store store #(do (log/debug :writing %) %) #(do (log/debug :reading %) %)))
Wraps the given `IEventStore` by piping all of the events going in through
`event-fn-in` and the ones coming out through `event-fn-out`. The callbacks
are functions of one argument which expect and event and produce an event,
several events or no events (`nil` or empty seq) synchronously.
`event-fn-in` can only produce a single event when given an event.
If the middleware returns multiple events in place of a single one, the
functions of `EventStore` will work as follows:
* `read-event` will return whatever `event-fn-out` returns
* `read-stream-*` concatenates the events produced by `event-fn-out`
Example:
(defn log
[store]
(wrap-store store
#(do (log/debug :writing %) %)
#(do (log/debug :reading %) %)))
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 |