Hi… playing around with Stuart Sierras component library I found some behavior (code at end) that I find odd. M sample has just two components, data and compute, where data is injected into compute. On start data associates a data map and on stop dissociates it. compute uses a value from data's map to compute.
What I found is that after system stop the started version of data is still associated to compute, while the data component in SystemMap is stopped. So, when do (def my-system (make-my-system {:factor 2})) (alter-var-root #'my-system component/start-system) (alter-var-root #'my-system component/stop-system) (my-compute (:mycomputecomp my-system) 16) my-compute should (as data map is nil'ed on stop) crash but doesn't. Calling (alter-var-root #'my-system component/stop-system) again fixes it and my-compute crashes as expected. Any ideas? Ciao …Jochen (ns foo.core (:require [com.stuartsierra.component :as component])) (defrecord MyDataComponent [data] component/Lifecycle (start [this] (println "Starting MyDataComponent") (assoc this :data {:foo 42})) (stop [this] (println "Stopping MyDataComponent") (dissoc this :data))) (defn my-data-component [] (->MyDataComponent nil)) (defn mydatacomp-foo [mydatacomp] (get-in mydatacomp [:data :foo])) (defrecord MyComputeComponent [factor mydatacomp] component/Lifecycle (start [this] (println "Starting MyComputeComponent") this) (stop [this] (println "Stopping MyComputeComponent") this)) (defn my-compute-component [factor] (map->MyComputeComponent {:factor factor})) (defn my-compute [mycomputecomp offset] (let [factor (:factor mycomputecomp) foo (mydatacomp-foo (:mydatacomp mycomputecomp))] (+ (* factor foo) offset))) (defn make-my-system [config-options] (let [{:keys [factor]} config-options] (component/system-map :mydatacomp (my-data-component) :mycomputecomp (component/using (my-compute-component factor) [:mydatacomp])))) ;;;;;; running ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (comment (def my-system (make-my-system {:factor 2})) (alter-var-root #'my-system component/start-system) (alter-var-root #'my-system component/stop-system) (my-compute (:mycomputecomp my-system) 16) ) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.