diff --git a/src/devcards/om/devcards/bugs.cljs b/src/devcards/om/devcards/bugs.cljs index daa7f0e5..f70e44fa 100644 --- a/src/devcards/om/devcards/bugs.cljs +++ b/src/devcards/om/devcards/bugs.cljs @@ -1025,6 +1025,58 @@ (dom/create-element "use" #js {:xlinkHref "#rectangle" :x "150"}))) +(def om-862-state (atom {:count 1})) +(def om-862-reconciler + (om/reconciler {:state om-862-state + :remotes [:remote] + :parser (om/parser + {:read (fn [{:keys [state]} key _] + {:value (get @state key)}) + :mutate (fn [{:keys [state]} key _] + {:value {} + :action #(swap! state + update :count inc) + :remote (= 'count/inc-by-each-remote + key)})}) + :send (fn [{:keys [remote]} cb] + (when remote + (let [resp {:count (inc (:count @om-862-state))} + query [:count]] + (cb resp query remote))))})) + +(defui om-862-Root + static om/IQuery + (query [this] + [:count]) + Object + (render [this] + (let [props (om/props this)] + (dom/div nil + (dom/div + nil + "Clicking first on should not + prevent from scheduling a + reconcile! Try clicking first on and + then try clicking on .") + (dom/button + #js {:onClick #(om/transact! + this '[(count/inc-by-each-remote)])} + "Should increment by 2") + (dom/button + #js {:onClick #(om/transact! + this '[(count/inc-only-client)])} + "Should increment by 1") + (dom/div nil (:count props)))))) +; Override om/*raf* to force the race condition that causes the abberant +; om-862 behavior +(set! om/*raf* (fn [f] + (println "*raf* override called") + (f))) +(defcard om-862-card + (dom-node + (fn [_ node] + (om/add-root! om-862-reconciler om-862-Root node)))) + (comment (require '[cljs.pprint :as pprint]) diff --git a/src/main/om/next.cljc b/src/main/om/next.cljc index 38396636..f0e8fc54 100644 --- a/src/main/om/next.cljc +++ b/src/main/om/next.cljc @@ -1314,9 +1314,11 @@ (swap! st update-in [:om.next/queries (or c root)] merge (merge (when query {:query query}) (when params {:params params}))) (when (and (not (nil? c)) (nil? reads)) - (p/queue! r [c])) + (p/queue! r [c]) + #?(:cljs (schedule-render! r))) (when-not (nil? reads) - (p/queue! r reads)) + (p/queue! r reads) + #?(:cljs (schedule-render! r))) (p/reindex! r) (let [rootq (if (not (nil? c)) (full-query c) @@ -2489,7 +2491,7 @@ q (if-not (nil? remote) (get-in st [:remote-queue remote]) (:queue st))] - (swap! state update-in [:queued] not) + (swap! state assoc :queued false) (if (not (nil? remote)) (swap! state assoc-in [:remote-queue remote] []) (swap! state assoc :queue []))