Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call p/dependencies only once #26

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/darkleaf/di/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@
(conj tail (apply f head args))))

(defn- stack-frame [key dep-type factory]
{:key key
:dep-type dep-type
:factory factory
:remaining-deps (seq (p/dependencies factory))})

(defn- build-obj [built-map factory]
(let [declared-deps (p/dependencies factory)
(let [deps (p/dependencies factory)]
{:key key
:dep-type dep-type
:factory factory
:deps deps
darkleaf marked this conversation as resolved.
Show resolved Hide resolved
:remaining-deps (seq deps)}))

(defn- build-obj [built-map head]
(let [factory (:factory head)
declared-deps (:deps head)
built-deps (select-keys built-map (keys declared-deps))]
(p/build factory built-deps)))

Expand Down Expand Up @@ -123,7 +126,7 @@
built-map))

:else
(let [obj (build-obj built-map factory)
(let [obj (build-obj built-map head)
stop (bound-fn* #(p/demolish factory obj))]
(vswap! *stop-list conj stop)
(case [obj dep-type]
Expand Down
Loading