adding ns to state order to avoid collisions

This commit is contained in:
anatoly 2015-11-29 23:36:26 -05:00
parent 6d2a8d3eec
commit 8e5926ac75

View file

@ -28,12 +28,15 @@
(and suspend (not resume)) (throw
(IllegalArgumentException. "suspendable state should have a resume function (i.e. missing :resume fn)"))))
(defn- with-ns [ns name]
(str ns "/" name))
(defmacro defstate [state & body]
(let [[state params] (macro/name-with-attributes state body)
{:keys [start stop suspend resume] :as lifecycle} (apply hash-map params)]
(validate lifecycle)
(let [s-meta (cond-> {:mount-state mount-state
:order (make-state-seq state)
:order (make-state-seq (with-ns *ns* state))
:start `(fn [] ~start)
:status #{:stopped}}
stop (assoc :stop `(fn [] ~stop))