Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dmitryn
Last active March 15, 2021 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitryn/eff1ac30948913490f6feff396f26b9f to your computer and use it in GitHub Desktop.
Save dmitryn/eff1ac30948913490f6feff396f26b9f to your computer and use it in GitHub Desktop.
inject-sub-cofx deref issue
(ns inject-sub-cofx
(:require [re-frame.core :refer [reg-sub subscribe]))
(reg-sub :bar
(fn [db]
(count db)))
(reg-sub :foo
(fn [_]
(subscribe [:bar]))
(fn [a _] a))
(comment
(def sub (subscribe [:foo]))
(deref sub)
(.-watching sub) ;; => nil
(reagent.ratom/dispose! sub)
(filter #(= :bar (get-in % [0 0 0])) @re-frame.subs/query->reaction) ; => ([[[:bar] []] #object[reagent.ratom.Reaction {:val 67}]]))
(reagent.ratom/run sub)
(.-watching sub) ;; => #js[#object[reagent.ratom.Reaction {:val 67}] #object[reagent.ratom.Reaction {:val 67}]]
(reagent.ratom/dispose! sub)
(filter #(= :bar (get-in % [0 0 0])) @re-frame.subs/query->reaction)) ;; => ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment