(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
(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
(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]
(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
(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]}
(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})
(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})
(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}])
(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}])
(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
(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
(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}})
(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-)
(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})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close