diff --git a/src/moira/event.cljs b/src/moira/event.cljs index a98335a..1aa5d18 100644 --- a/src/moira/event.cljs +++ b/src/moira/event.cljs @@ -1,5 +1,5 @@ (ns moira.event - "Implement [[Factory]] for producing Application Events with unique + "Create [[Factory]] for producing Application Events with unique [[EventId|Event IDs]] and guaranteed ordering based on a [logical clock](https://en.wikipedia.org/wiki/Logical_clock)." diff --git a/src/moira/log/module.cljs b/src/moira/log/module.cljs index 9bfb461..5debd27 100644 --- a/src/moira/log/module.cljs +++ b/src/moira/log/module.cljs @@ -1,17 +1,33 @@ (ns moira.log.module + "Instrument Application Log by setting up + [[moira.log.event-emitter/EventEmitter|EventEmitter]] as a module." + (:require [clojure.spec.alpha :as s] [moira.log.event-emitter :as event-emitter])) -(defn start [state] +(defn start + "Create an [[moira.log.event-emitter/EventEmitter|EventEmitter] instance and + store it as part of the module's `state`." + + [state] + (assoc state :event-emitter (event-emitter/create))) -(defn stop [{:keys [event-emitter]}] +(defn stop + "Wrap up [[moira.log.event-emitter/EventEmitter|EventEmitter] instance and + clear module's `state`." + + [{:keys [event-emitter]}] + (event-emitter/unlisten event-emitter) nil) (s/def ::export (s/map-of #{:off :on :put} ifn?)) -(defn export [{:keys [event-emitter]}] +(defn export + "Export API for interacting with the Application Log." + + [{:keys [event-emitter]}] {:post [(s/valid? ::export %)]} @@ -19,6 +35,10 @@ :on (partial event-emitter/listen event-emitter) :put (partial event-emitter/emit event-emitter)}) -(def default {:export #'export - :start #'start - :stop #'stop}) +(def default + "Defaults that will automatically be injected into each + [[moira.application/Application|Application]] as `:app-log`." + + {:export #'export + :start #'start + :stop #'stop}) diff --git a/src/moira/log/txs.cljs b/src/moira/log/txs.cljs index 53b43bb..fbb26ce 100644 --- a/src/moira/log/txs.cljs +++ b/src/moira/log/txs.cljs @@ -1,6 +1,5 @@ (ns moira.log.txs - "Interceptors for integrating `:app-log` into the - [[moira.transition|transition]] flow." + "Integrate `:app-log` into the [[moira.transition|transition]] flow." (:require [moira.log.event-emitter :as event-emitter] [moira.log.module :as log.module]