Created
September 8, 2010 10:55
-
-
Save pepijndevos/569958 to your computer and use it in GitHub Desktop.
Plugin system for Utterson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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