This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-07
Channels
- # alda (7)
- # beginners (4)
- # boot (108)
- # cljsrn (40)
- # clojure (24)
- # clojure-berlin (1)
- # clojure-dev (20)
- # clojure-russia (21)
- # clojurescript (115)
- # clojurescript-ios (1)
- # cursive (8)
- # data-science (5)
- # datascript (3)
- # hoplon (313)
- # jobs (1)
- # ldnclj (2)
- # off-topic (19)
- # om (115)
- # portland-or (3)
- # re-frame (9)
- # yada (2)
Hello guys... in order to negate a subscription, do I need to create another subscription or deref subscribe and then negate the result?
negate a subscription?
Perhaps this will help: https://groups.google.com/forum/#!topic/reagent-project/kNUIgLdsDuo
I mean if I have (subscribe [:console-created? :cljs-console])
and what I need to return is actually the negation..do I have to (not @(subscribe [:console-created? :cljs-console]))
?
i would like to share code in the register-sub
yes it works with the trick above, you first deref the result of subscribe and then apply not
Be careful ... that not
won't "rerun" when the subscription gets a new value unless you ....
(let [val (subscribe [:console-created? :cljs-console])
not-val (reaction (not @val))] ;; <-- if val changes, also make not-val change
...
Or just use (not @val)
in the body of the rendererBut definitely do NOT do this:
(let [val (not @ (subscribe [:console-created? :cljs-console]))]
...
yes it is directly in a re-com :disabled?
property, therefore should be inside a component