Skip to content

Instantly share code, notes, and snippets.

@marcomanzi
Created November 12, 2013 22:56
(def ^:private actions :actions)
(def ^:private sigVal :sigVal)
(defn wire [s a] {sigVal s, actions a})
(defn- update-with [w k v f] (assoc w k (f w v)))
(defn- launch-actions [w s]
(let [_ (if (not= s (w get-signal)) (doall (map #(%) (w actions))))]
s))
(defn- cons-actions [w a] (cons a (actions w)))
(defn get-signal [wire] (sigVal wire))
(defn set-signal [w s] (update-with w sigVal s launch-actions))
(defn add-action [w a] (update-with w actions a cons-actions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment