diff --git a/examples/todomvc/src/todomvc/events.cljs b/examples/todomvc/src/todomvc/events.cljs index 34cae905..257ac235 100644 --- a/examples/todomvc/src/todomvc/events.cljs +++ b/examples/todomvc/src/todomvc/events.cljs @@ -7,6 +7,8 @@ [malli.generator :as mg] [day8.re-frame-10x.inlined-deps.re-frame.v1v1v2.re-frame.core :as rf])) +(reg-event-db :bad-event (fn [db _] db)) + ;; -- Interceptors -------------------------------------------------------------- ;; ;; Interceptors are a more advanced topic. So, we're plunging into the deep diff --git a/examples/todomvc/src/todomvc/views.cljs b/examples/todomvc/src/todomvc/views.cljs index abf7d39a..5a731c85 100644 --- a/examples/todomvc/src/todomvc/views.cljs +++ b/examples/todomvc/src/todomvc/views.cljs @@ -98,7 +98,22 @@ [:a {:on-click #(dispatch [:flood]) :style {:cursor "pointer"}} - "Flood Events & app-db"]] + "Flood Events & app-db"] + " | " + [:a + {:on-click #(dispatch [:bad-event]) + :style {:cursor "pointer"}} + "Dispatch Test Event"] + [:br] + [:a + {:on-click #(re-frame.core/clear-global-interceptor :day8.re-frame-10x/internal) + :style {:cursor "pointer"}} + "Break Event"] + " | " + [:a + {:on-click #(do (day8.re-frame-10x/fix-db-noop)) + :style {:cursor "pointer"}} + "Fix Event"]] [:section#todoapp [task-entry] (when (seq @(subscribe [:todos])) diff --git a/src/day8/re_frame_10x.cljs b/src/day8/re_frame_10x.cljs index 0af31390..7ebe5837 100644 --- a/src/day8/re_frame_10x.cljs +++ b/src/day8/re_frame_10x.cljs @@ -146,6 +146,14 @@ (patch-wrap-funs) (patch-next-tick)) +(defn fix-db-noop [] + (re-frame.core/reg-global-interceptor + (re-frame.core/->interceptor + :id :day8.re-frame-10x/internal + :after #(assoc-in % [:effects :db :day8.re-frame-10x/internal] (gensym))))) + +(fix-db-noop) + (defn init! [] (patch!) diff --git a/src/day8/re_frame_10x/tools/metamorphic.cljc b/src/day8/re_frame_10x/tools/metamorphic.cljc index 57b8cf44..b7632200 100644 --- a/src/day8/re_frame_10x/tools/metamorphic.cljc +++ b/src/day8/re_frame_10x/tools/metamorphic.cljc @@ -220,6 +220,13 @@ (let [current-match (:current-match state) previous-event (:previous-event state) no-match? (nil? current-match)] + (let [m (zipmap [:no-match? :quiescent? :start? :run? :state] + (map boolean [no-match? + (quiescent? event) + (start-of-epoch-and-prev-end? event state) + (event-run? event) + :else]))] + (println (first (first (filter (comp boolean second) m))))) (-> (cond ;; No current match yet, check if this is the start of an epoch diff --git a/src/day8/reagent/impl/batching.cljs b/src/day8/reagent/impl/batching.cljs index 77e7d115..b369c572 100644 --- a/src/day8/reagent/impl/batching.cljs +++ b/src/day8/reagent/impl/batching.cljs @@ -16,7 +16,9 @@ {:op-type :raf} (f) (trace/with-trace {:op-type :raf-end}) + (println "scheduled.") (when (false? (.-scheduled? reagent.impl.batching/render-queue)) + (println "attained quiescience.") (trace/with-trace {:op-type :reagent/quiescent})))))) (defn patch-next-tick