This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-26
Channels
- # admin-announcements (70)
- # aws (1)
- # beginners (17)
- # boot (37)
- # business (1)
- # cider (2)
- # cljs-dev (56)
- # cljsrn (6)
- # clojure (151)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-poland (5)
- # clojure-russia (34)
- # clojure-taiwan (1)
- # clojurescript (289)
- # clojurex (2)
- # cursive (16)
- # datavis (3)
- # datomic (12)
- # editors (10)
- # emacs (3)
- # hoplon (17)
- # ldnclj (5)
- # lein-figwheel (12)
- # leiningen (1)
- # liberator (1)
- # off-topic (23)
- # om (116)
- # onyx (39)
- # parinfer (44)
- # portland-or (1)
- # reagent (34)
- # yada (6)
well I ended up just making a component that derefs an r/atom that contains a buffer of all the transactions and then immediately runs the transact! fn on the buffer and then clears it. then you just have to make sure to add the [transactions] component to the main app state.
i mostly just want them to all happen at the same time so that none of the reactions to the tx report queue get skipped
in this om next is clearer
ops sorry thinking out loud 😄
@mpdairy: > does anyone know how I could make a non-component function run after every react update With reagent, the components update in response to the state updates. So wouldn't you simply listen to changes in the state? Seems off to me that you would be listening for components running ... when they are simply a symptom of something else occuring.
Having said that .... with release 0.6.0 of reagent (currently in SNAPSHOT), you can provide a function to be run AFTER the next annimation frame (components get updated). Would that do?
https://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L320-L325
Oh, yes, thanks @mikethompson that's just what I was looking for!
If you want to use it now:
- clone the reagent repo to your machine
- do a lein install
on your machine (which will put it into your local Maven repo)
- change the deps in your project's project.clj to be for the 0.6.0-SNAPSHOT
Having said that I can't vouch for its stability. I haven't tried it.
right, well I'd want to include it in my "posh" library so I'd better just stick with the js set interval for now and then hook into that function later. it is exactly what I was looking for
@mpdairy: I can't vouch for it but ... reagent.impl.batching/do-after-flush
might well give you the same functionality in v0.5.1
https://github.com/reagent-project/reagent/blob/v0.5.1/src/reagent/impl/batching.cljs#L78-L79
Correction: looks like you should use: do-later
Hmm. Actually, I can see pros and cons to the two functions, depending on your needs
so, i was wondering, if you have a reaction and something updates it several times between render frames, would it only end up reacting to the last value that the reaction ended up with?
Not in this part of the world
do-later
will schedule an annimationFrame
do-after-flush
won't
Ooh I worked remotely for a foreign company last year and it was always a shock when they weren't celebrating our holidays.
So do-later
will run f
within 16ms
Whereas do-after-flush
just puts f
onto the end of the animationFrame whenever that might be ... but something else will have to trigger that annimationFrame.
So, the right one depends on your requirements
do-later
is a one off
So your f
would have to reschedule itself, via another call to do-later