Liking cljdoc? Tell your friends :D

hara.event


*issue-managers*clj


*issue-optmap*clj


*signal-manager*clj


chooseclj

(choose label & args)

used within a manage form to definitively fail the system

(manage (raise :error (option :specify [a] a)) (on :error _ (choose :specify 42))) => 42

used within a manage form to definitively fail the system

(manage (raise :error
               (option :specify [a] a))
        (on :error
            _
            (choose :specify 42)))
=> 42
raw docstring

clear-listenersclj

(clear-listeners)

empties all event listeners

(clear-listeners) ;; all defined listeners will be cleared

empties all event listeners

(clear-listeners)
;; all defined listeners will be cleared 
raw docstring

continueclj

(continue body)

used within a manage form to continue on with a particular value

(manage [1 2 (raise :error)] (on :error _ (continue 3))) => [1 2 3]

used within a manage form to continue on with a particular value

(manage [1 2 (raise :error)]
        (on :error
            _
            (continue 3)))
=> [1 2 3]
raw docstring

defaultclj

(default & args)

used within either a raise or escalate form to specify the default option to take if no other options arise.

(raise :error (option :specify [a] a) (default :specify 3)) => 3

(manage (raise :error (option :specify [a] a) (default :specify 3)) (on :error [] (escalate :error (default :specify 5)))) => 5

used within either a raise or escalate form to specify the default option to take if no other options arise. 

(raise :error
       (option :specify [a] a)
       (default :specify 3))
=> 3

(manage
 (raise :error
        (option :specify [a] a)
        (default :specify 3))
 (on :error []
     (escalate :error
               (default :specify 5))))
=> 5
raw docstring

deflistenercljmacro

(deflistener name checker bindings & more)

installs a global signal listener

(def -counts- (atom {}))

(deflistener -count-listener- :log [msg] (swap! -counts- update-in [:counts] (fnil #(conj % (count msg)) [])))

(signal [:log {:msg "Hello World"}])

(signal [:log {:msg "How are you?"}])

@-counts- => {:counts [11 12]}

installs a global signal listener

(def -counts- (atom {}))

(deflistener -count-listener- :log
  [msg]
  (swap! -counts- update-in [:counts] (fnil #(conj % (count msg)) [])))

(signal [:log {:msg "Hello World"}])

(signal [:log {:msg "How are you?"}])

@-counts-
=> {:counts [11 12]}
raw docstring

escalatecljmacro

(escalate data & forms)

used within a manage form to add further data on an issue

(manage [1 2 (raise :error)] (on :error _ (escalate :escalated))) => (throws-info {:error true :escalated true})

used within a manage form to add further data on an issue

(manage [1 2 (raise :error)]
        (on :error
            _
            (escalate :escalated)))
=> (throws-info {:error true
                 :escalated true})
raw docstring

failclj

(fail)
(fail data)

used within a manage form to definitively fail the system

(manage (raise :error) (on :error _ (fail :failed))) => (throws-info {:error true})

used within a manage form to definitively fail the system

(manage (raise :error)
        (on :error
            _
            (fail :failed)))
=> (throws-info {:error true})
raw docstring

install-listenerclj

(install-listener id checker handler)

adds an event listener, deflistener can also be used

(install-listener '-hello- :msg (fn [{:keys [msg]}] (str "recieved " msg)))

(list-listeners) => (contains-in [{:id '-hello- :checker :msg}])

adds an event listener, `deflistener` can also be used

(install-listener '-hello-
                  :msg
                  (fn [{:keys [msg]}]
                    (str "recieved " msg)))

(list-listeners)
=> (contains-in [{:id '-hello-
                  :checker :msg}])
raw docstring

list-listenersclj

(list-listeners)
(list-listeners checker)

shows all event listeners

(deflistener -hello-listener- :msg [msg] (str "recieved " msg))

(list-listeners) => (contains-in [{:id 'hara.event-test/-hello-listener-, :checker :msg}])

shows all event listeners

(deflistener -hello-listener- :msg
  [msg]
  (str "recieved " msg))

(list-listeners)
=> (contains-in [{:id 'hara.event-test/-hello-listener-,
                  :checker :msg}])
raw docstring

managecljmacro

(manage & forms)

manages a raised issue, like try but is continuable:

(manage [1 2 (raise :error)] (on :error _ 3)) => 3

manages a raised issue, like try but is continuable:

(manage [1 2 (raise :error)]
        (on :error
            _
            3))
=> 3
raw docstring

raisecljmacro

(raise content & [msg & forms])

raise an issue, like throw but can be conditionally managed as well as automatically resolved:

(raise [:error {:msg "A problem."}]) => (throws-info {:error true :msg "A problem."})

(raise [:error {:msg "A resolvable problem"}] (option :something [] 42) (default :something)) => 42

raise an issue, like throw but can be conditionally managed as well as automatically resolved:

(raise  [:error {:msg "A problem."}])
=> (throws-info {:error true
                 :msg "A problem."})

(raise [:error {:msg "A resolvable problem"}]
       (option :something [] 42)
       (default :something))
=> 42
raw docstring

signalclj

(signal data)
(signal data manager)

signals an event that is sent to, it does not do anything by itself

(signal :anything) => ()

(deflistener -hello- _ e e)

(signal :anything) => '({:id hara.event-test/-hello- :result {:anything true}})

signals an event that is sent to, it does not do anything by itself

(signal :anything) => ()

(deflistener -hello- _
  e
  e)

(signal :anything)
=> '({:id hara.event-test/-hello- :result {:anything true}})
raw docstring

uninstall-listenerclj

(uninstall-listener id)

uninstalls a global signal listener

(uninstall-listener 'hara.event-test/-hello-)

uninstalls a global signal listener

(uninstall-listener 'hara.event-test/-hello-)
raw docstring

with-temp-listenercljmacro

(with-temp-listener [checker handler] & body)

used for isolating and testing signaling

(with-temp-listener [{:id string?} (fn [e] "world")] (signal {:id "hello"})) => '({:result "world", :id :temp})

used for isolating and testing signaling

(with-temp-listener [{:id string?}
                     (fn [e] "world")]
  (signal {:id "hello"}))
=> '({:result "world", :id :temp})
raw docstring

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

× close