Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Fix db noop #403

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/todomvc/src/todomvc/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion examples/todomvc/src/todomvc/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
8 changes: 8 additions & 0 deletions src/day8/re_frame_10x.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
7 changes: 7 additions & 0 deletions src/day8/re_frame_10x/tools/metamorphic.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/day8/reagent/impl/batching.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down