Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plugin system for Utterson
(ns utterson.plugin)
(def hooks (atom {}))
(defn register [hook function]
(swap! hooks update-in [hook] conj function))
(defn do-hook [hook & args]
(apply (apply comp (hook @hooks)) args))
(register :test +)
(register :test inc)
(register :test #(do-hook :foo %))
(register :test println)
(register :foo #(* % 5))
(do-hook :test 1 2 3)
;35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.