juxt / clip

Light structure and support for dependency injection
MIT License
228 stars 15 forks source link

:pre-start unrelated side effects #37

Closed abritov closed 1 year ago

abritov commented 1 year ago

CLJS system-config:

(def system-config2
  {:executor juxt.clip.promesa/exec
   :components
   {:db {:start (list promesa.core/resolved "foo")
         :pre-start (list println "initializing database component")
         :post-start (list println "database component initialized")}
    :post-db {:start (list println "post-db" (clip/ref :db))}
    :web {:start (list p/resolved (list fastify (clj->js {:logger true})))
          :pre-start (list println "initializing web-server component")
          :post-start listen}
    :db-debug {:start (list println "db-debug" (clip/ref :db))}}})

(defn start! []
  (clip/start system-config))

Output:

initializing database component
database component initialized
post-db foo
initializing web-server component
db-debug nil

Expected:

initializing database component
database component initialized
post-db foo
initializing web-server component
db-debug foo

If you comment :pre-start (list println "initializing web-server component") then system works as expected

shadow-cljs.edn:

{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[funcool/promesa "4.0.2"]
  [binaryage/oops "0.7.2"]
  [juxt/clip "0.28.0"]]

 :builds
 {:app
  {:main app.core/main
   :target :node-script
   :compiler-options {:infer-externs :auto}
   :output-to "dist/app.js"
   :devtools
   {:after-load app.core/start!
    :before-load-async app.core/stop!}}
  :test
  {:target :node-test
   :output-to "dist/tests.js"
   :autorun true}}}

"shadow-cljs": "2.25.2" Clojure CLI version 1.11.1.1323

SevereOverfl0w commented 1 year ago

Fixed in 0.29.0. Thanks for your report!