Liking cljdoc? Tell your friends :D
Clojure only.

everest.store.middleware


wrap-storeclj

(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 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 %) %)))

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 %) %)))
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close