Skip to content

Commit

Permalink
[flows] Memoize topsort correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Aug 12, 2024
1 parent 09e2d71 commit cf5e836
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/re_frame/flow/alpha.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
reverse
(map flows)))

(def topsort* (memoize topsort))

(defn default [id]
{:id id
:path [id]
Expand Down Expand Up @@ -169,6 +171,6 @@
:after (comp (fn [ctx]
(let [all-flows (with-cleared @flows)]
(swap! flows vary-meta dissoc ::cleared)
(reduce run ctx ((memoize topsort) all-flows))))
(reduce run ctx (topsort* all-flows))))
(fn [{{:keys [db]} :effects :as ctx}]
(assoc ctx :re-frame/pre-flow-db db)))}))

0 comments on commit cf5e836

Please sign in to comment.