Reaction is a library to manage and dispatch actions.
It is based around the Atom principle of ClojureScript.
Please add [reaction "0.1.2"] to your project.clj to use it.
It provides a visual interface to display the actions list/history.
An action is a modification that will be apply to an atom (The same way you'd do it around a swap!)
(ns whatever.core
(:require [reaction.core :refer-macros [defaction]]))
(defaction test-action
"Increments the counter of 1"
[m]
(update m :counter inc))An action! is a function used to dispatch actions(!) in an asynchronous way.
(ns whatever.core
(:require [reaction.core :refer-macros [defaction defaction! dispatch!]]))
(defaction test-action
"Increments the counter of 1"
[m]
(update m :counter inc))
(defaction! test-action
"Dispatches [:test-action] after 1s"
[state]
(.setTimeout js/window
#(dispatch! state [:test-action])
1000))You can use reaction to recur on the action/action!
(Note: no need to refer reaction)
(ns whatever.core
(:require [reaction.core :refer-macros [defaction]]))
(defaction increment
([m]
(reaction m 1))
([m i]
(update m :counter #(% + i))))dispatch! is a macro used to dispatch one or multiple actions(!)
(ns whatever.core
(:require [reaction.core :refer-macros [defaction defaction! dispatch!]]))
(dispatch! state
[:test-action]
:test-action
[:increment 1]
[! :test-action])bind-actions-list can be called to mount the action-list/history.
(ns whatever.core
(:require [reaction.core :refer [bind-actions-list]]))
(bind-actions-list)