Skip to content

Commit 3707365

Browse files
committed
Test out removing one of four Reagent queues
1 parent 5baa4cf commit 3707365

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

src/reagent/impl/batching.cljs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
fake-raf)
2525
w))))
2626

27-
(defn compare-mount-order
28-
[^clj c1 ^clj c2]
29-
(- (.-cljsMountOrder c1)
30-
(.-cljsMountOrder c2)))
31-
3227
;; See reagent.dom.client/render and hydrate-root
3328
;;
3429
;; On React 19 react-dom/flushSync is used to flush all Reagent ratom changes
@@ -40,18 +35,6 @@
4035
(fn noop [f]
4136
(f)))
4237

43-
(defn run-queue [a]
44-
;; sort components by mount order, to make sure parents
45-
;; are rendered before children
46-
(.sort a compare-mount-order)
47-
(react-flush
48-
(fn []
49-
(dotimes [i (alength a)]
50-
(let [^js/React.Component c (aget a i)]
51-
(when (true? (.-cljsIsDirty c))
52-
(.forceUpdate c)))))))
53-
54-
5538
;; Set from ratom.cljs
5639
(defonce ratom-flush (fn []))
5740

@@ -95,20 +78,14 @@
9578
(set! (.-beforeFlush this) nil)
9679
(run-funs fs)))
9780

98-
(flush-render [this]
99-
(when-some [fs (.-componentQueue this)]
100-
(set! (.-componentQueue this) nil)
101-
(run-queue fs)))
102-
10381
(flush-after-render [this]
10482
(when-some [fs (.-afterRender this)]
10583
(set! (.-afterRender this) nil)
10684
(run-funs fs)))
10785

10886
(flush-queues [this]
10987
(.flush-before-flush this)
110-
(ratom-flush)
111-
(.flush-render this)
88+
(react-flush (fn [] (ratom-flush)))
11289
(.flush-after-render this)))
11390

11491
(def render-queue (->RenderQueue false))
@@ -120,12 +97,7 @@
12097
(.flush-after-render render-queue))
12198

12299
(defn queue-render [^clj c]
123-
(when-not (.-cljsIsDirty c)
124-
(set! (.-cljsIsDirty c) true)
125-
(.queue-render render-queue c)))
126-
127-
(defn mark-rendered [^clj c]
128-
(set! (.-cljsIsDirty c) false))
100+
(.forceUpdate c))
129101

130102
(defn do-before-flush [f]
131103
(.add-before-flush render-queue f))

src/reagent/impl/component.cljs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@
199199
(fn componentWillUnmount []
200200
(this-as c
201201
(some-> (gobj/get c "cljsRatom") ratom/dispose!)
202-
(batch/mark-rendered c)
203202
(when-not (nil? f)
204203
(.call f c c))))
205204

@@ -255,7 +254,6 @@
255254
(this-as c (if util/*non-reactive*
256255
(do-render c compiler)
257256
(let [^clj rat (gobj/get c "cljsRatom")]
258-
(batch/mark-rendered c)
259257
(if (nil? rat)
260258
(ratom/run-in-reaction #(do-render c compiler) c "cljsRatom"
261259
batch/queue-render rat-opts)
@@ -306,7 +304,6 @@
306304
(construct this props))
307305
(when get-initial-state
308306
(set! (.-state this) (get-initial-state this)))
309-
(set! (.-cljsMountOrder this) (batch/next-mount-count))
310307
this))]
311308

312309
(gobj/extend (.-prototype cmp) (.-prototype react/Component) methods)
@@ -412,7 +409,6 @@
412409
_ (when-not (.-current state-ref)
413410
(let [obj #js {}]
414411
(set! (.-forceUpdate obj) (fn [] (update-count inc)))
415-
(set! (.-cljsMountOrder obj) (batch/next-mount-count))
416412
;; Use reagentRender name, as that is also used
417413
;; by class components, and some checks.
418414
;; reagentRender is replaced with form-2 inner fn,
@@ -438,8 +434,6 @@
438434
;; so reaction fn will always see the latest value.
439435
(set! (.-argv reagent-state) argv)
440436

441-
(batch/mark-rendered reagent-state)
442-
443437
;; static-fns :render
444438
(if (nil? rat)
445439
(ratom/run-in-reaction

0 commit comments

Comments
 (0)