This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-12
Channels
- # admin-announcements (1)
- # arachne (3)
- # cider (11)
- # cljsrn (5)
- # clojure (26)
- # clojure-android (10)
- # clojure-greece (8)
- # clojure-russia (5)
- # clojure-spec (7)
- # clojure-uk (3)
- # clojurescript (16)
- # clojurex (38)
- # core-async (1)
- # css (3)
- # cursive (42)
- # dirac (2)
- # hoplon (28)
- # keechma (1)
- # lein-figwheel (2)
- # leiningen (1)
- # mount (3)
- # om (132)
- # onyx (46)
- # re-frame (53)
- # reagent (17)
- # spacemacs (7)
- # specter (50)
- # untangled (2)
- # yada (3)
@danielcompton: hey Daniel - actually, cljs-devtools is already installed, but perhaps the output looks different to what you expect due to the additional configuration - I blindly followed the instructions here regarding clairvoyant and re-frame-tracer: https://github.com/Day8/re-frame/wiki/Debugging
cljs-devtools not fully configured! (thanks) updated console screengrab
that second call to get-vote-by-id was from the repl
Perhaps a silly question, but can I (subscribe) an arbitrary side-effecting function (ie that's not a reagent component) to an event?
Sorry not an event
Have an arbitrary function called each time a subscription changes, is what I meant
something like
(let [sel (subscribe [:selection-changed])]
(println “Selection is:” @sel))
also tried
(let [sel (subscribe [:selection-changed])]
(add-watch sel :key (fn [ref key old new] (println "Selection is:" new))))
neither of those work
(register-sub :loading?
(fn loading? [db _]
(my-function-that-does-what-i-want @db)
(reaction (:loading? @db))))
@wasser: :selection-changed is a subscription i setup with register-sub
This looks like you want to kick off a (long-running) asynchronous task and then have your subscriptions re-render when it finishes. If that's true, the wiki has a good discussion of a workable approach: https://github.com/Day8/re-frame/wiki/Talking-To-Servers
@escherize’s approach would probably work for me
though it’s then fixed for teh life of the subscription
ideally i’d want something like add-watch
that i can add & remove at will
@wasser: i don’t have a specific use-case ironed out
just trying to figure out how to have arbitrary code trigger in response to a change in subscription
i guess i can just add/remove the entire subscription, & optionally set the listener function when i need it
it started out as a debugging exercise 🙂
but it got me wondering more generally
shouldn’t i expect add-watch to work?
(subscribe) returns a ratom, which implements IWatchable
or maybe it doesn’t return a ratom, maybe only a reaction
let me check
yeah it is
but Reaction implements IWatchable too
maybe i need this :auto-run business
aah figured (it/something) out
(let [sel (subscribe [:selection])]
(run!
(println “Selection:" @sel))))
does what i want
though, i don’t think i can de-register it
ah you can, if you require dispose! from reagent.ratom
(defn listener []
(let [sel (subscribe [:selection])
state (atom {:count 0})]
(swap! state
assoc :listener
(run!
(println "Sselection:" @sel)
(swap! state update :count inc)
(when (< 3 (:count @state))
(dispose! (:listener @state)))))))
so that will listen for 3 changes then de-reg itself
@mikethompson: curious to hear your thoughts RE http://elm-lang.org/blog/farewell-to-frp
@pauldelany: in this code block
[:div
[:div (str "cv: " @cv)]
[:div (str "Current Vote id: " @current-vote-id)]]
is @current-vote-id
returning anything?@danielcompton: yep - that's evaluating correctly (to 1, in the instance shown in the screengrab)
what happens if you take out the filterv
in get-vote-by-id
, and just return all the votes?
do they all show up in the div?
The root cause of ^^ was a string was being set based on a cb from a secretary route handler.