Fork me on GitHub
#reagent
<
2015-11-26
>
mpdairy03:11:48

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.

mpdairy03:11:02

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

richiardiandrea03:11:35

in this om next is clearer

richiardiandrea03:11:50

ops sorry thinking out loud 😄

mpdairy03:11:22

actually maybe I'll just use js/setinterval

mikethompson04:11:13

@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.

mikethompson04:11:16

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?

mpdairy04:11:39

Oh, yes, thanks @mikethompson that's just what I was looking for!

mpdairy04:11:20

though I guess I'll have to wait for it to get out of snapshot

mikethompson04:11:41

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

mikethompson04:11:00

Having said that I can't vouch for its stability. I haven't tried it.

mpdairy04:11:14

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

mikethompson04:11:09

@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

mpdairy04:11:15

Oh, sweet, that does look promising

mikethompson04:11:26

Correction: looks like you should use: do-later

mikethompson04:11:29

Hmm. Actually, I can see pros and cons to the two functions, depending on your needs

mpdairy04:11:10

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?

mpdairy04:11:35

ok good, I think that was my problem then

mpdairy05:11:34

what's the difference between do-later and do-after-flush?

mpdairy05:11:48

Oh, happy thanksgiving

mikethompson05:11:20

Not in this part of the world simple_smile

mikethompson05:11:42

do-later will schedule an annimationFrame

mikethompson05:11:54

do-after-flush won't

mpdairy05:11:53

Ooh I worked remotely for a foreign company last year and it was always a shock when they weren't celebrating our holidays.

mikethompson05:11:12

So do-later will run fwithin 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.

mikethompson05:11:17

So, the right one depends on your requirements

mpdairy05:11:49

will do-later keep calling f after every frame?

mpdairy05:11:19

or maybe I could have f call do-later

mikethompson05:11:23

do-later is a one off

mikethompson05:11:47

So your f would have to reschedule itself, via another call to do-later

mbertheau15:11:34

Anybody used (react-)quill with reagent?