Skip to content
Snippets Groups Projects
Commit e4188cdf authored by Cam Saül's avatar Cam Saül
Browse files

Merge pull request #269 from metabase/hooks_are_defonce

give defhook defonce semantics so we don't lose any functions when
parents 50487f3c b2d51d07
No related branches found
No related tags found
No related merge requests found
......@@ -44,10 +44,10 @@
A hook is simply an atom storing a set of functions that you can run at any time with `run-hook`."
[hook-name & [docstr?]]
{:arglists '([hook-name docstr?])}
`(do (def ~hook-name
(atom #{}))
(alter-meta! #'~hook-name merge {:doc ~docstr?
:type ::hook})))
`(defonce ~(vary-meta hook-name assoc
:doc docstr?
:type ::hook)
(atom #{})))
;; TODO Should we require that F be a var so as to avoid duplicate lambdas being added ?
(defn add-hook!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment