Skip to content

Commit

Permalink
Refactor reagent monkey patching
Browse files Browse the repository at this point in the history
  • Loading branch information
superstructor committed Feb 24, 2021
1 parent 69238a4 commit e9cd382
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/day8/re_frame_10x.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[day8.re-frame-10x.subs]
[day8.re-frame-10x.events]
[day8.re-frame-10x.db :as trace.db]
[day8.reagent.impl.component]
[day8.reagent.impl.batching]
[day8.reagent.impl.component :refer [patch-wrap-funs patch-custom-wrapper]]
[day8.reagent.impl.batching :refer [patch-next-tick]]
[day8.re-frame-10x.inlined-deps.re-frame.v1v1v2.re-frame.core :as rf]
[day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.core :as r]
[day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.dom :as rdom]))
Expand All @@ -19,7 +19,9 @@
(defn init-tracing!
"Sets up any initial state that needs to be there for tracing. Does not enable tracing."
[]
#_(monkey-patch-reagent))
(patch-custom-wrapper)
(patch-wrap-funs)
(patch-next-tick))


(defn resizer-style [draggable-area]
Expand Down
4 changes: 3 additions & 1 deletion src/day8/reagent/impl/batching.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
(when (false? (.-scheduled? reagent.impl.batching/render-queue))
(trace/with-trace {:op-type :reagent/quiescent}))))))

(set! reagent.impl.batching/next-tick next-tick)
(defn patch-next-tick
[]
(set! reagent.impl.batching/next-tick next-tick))
12 changes: 8 additions & 4 deletions src/day8/reagent/impl/component.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@
cljs-ratom (gobj/get c "cljsRatom")]
(trace/merge-trace!
{:tags {:reaction (interop/reagent-id cljs-ratom)
:intput-signals (when cljs-ratom
(map interop/reagent-id (gobj/get cljs-ratom "watching" :none)))}})
:input-signals (when cljs-ratom
(map interop/reagent-id (gobj/get cljs-ratom "watching" :none)))}})
res)))))))

(set! reagent.impl.component/wrap-funs wrap-funs)
(defn patch-wrap-funs
[]
(set! reagent.impl.component/wrap-funs wrap-funs))

(defonce original-custom-wrapper reagent.impl.component/custom-wrapper)

Expand All @@ -75,4 +77,6 @@
(.call (original-custom-wrapper key f) c c)))
(original-custom-wrapper key f)))

(set! reagent.impl.component/custom-wrapper custom-wrapper)
(defn patch-custom-wrapper
[]
(set! reagent.impl.component/custom-wrapper custom-wrapper))

0 comments on commit e9cd382

Please sign in to comment.