technomancy / robert-hooke

Hooke your Clojure functions!
Other
358 stars 27 forks source link

Isn't `clear-hooks` redundant? #19

Open kindlychung opened 9 years ago

kindlychung commented 9 years ago

Isn't clear-hooks redundant? Eventually all hooks are cleared anyways.

(defn- clear-hook-mechanism [target-var]
  (alter-var-root target-var
                  (constantly (original target-var))))

(defn clear-hooks
  "Remove all hooks from target-var."
  [target-var]
  (when-let [hooks (hooks target-var)]
    (swap! hooks empty)
    (clear-hook-mechanism target-var)))