Fork me on GitHub
#om
<
2017-02-12
>
levitanong03:02:27

@sova: that's a solution to a component not updating. My issue is the component updates milliseconds too late, causing a flicker. :(

levitanong05:02:00

@anmonteiro @sova I seem to have gotten it to work. (p/reconcile! reconciler) seems to do the job. (not even (.reconciler! reconciler) for some reason.)

anmonteiro05:02:19

probably because the name is munged. (.reconcile_BANG_ reconciler) would probably do it

anmonteiro05:02:29

not that you wanna do it 馃檪

anmonteiro05:02:13

@levitanong hrm, so now that you discovered that works, I may have a less hacky solution for you 馃檪

levitanong05:02:33

force-root-render! also works btw

anmonteiro05:02:53

so Om Next has this async rendering loop, which on browsers is implemented through requestAnimationFrame

anmonteiro05:02:45

but requestAnimationFrame won't probably exist in React Native

levitanong05:02:59

so it鈥檚 on the timeout loop

anmonteiro05:02:06

so Om Next falls back to setTimeout

anmonteiro05:02:21

that might be flaky for a bunch of reasons

anmonteiro05:02:28

@levitanong you can override the function that queues the render loop by binding om.next/*raf*

levitanong05:02:35

(looks like requestAnimationFrame exists on react native though. https://facebook.github.io/react-native/docs/timers.html)

levitanong05:02:55

but would overriding the function work anyway?

anmonteiro06:02:10

you could even make it synchronous

levitanong06:02:58

and i suppose I could override *raf*, and somehow unbind it later on to bring it back to asynchronous rendering?

anmonteiro06:02:00

just set! it to nil and requestAnimationFrame will be called

levitanong06:02:20

nice! will try that out. Thanks, @anmonteiro!

levitanong06:02:19

@anmonteiro overriding *raf* works! Unsetting it doesn鈥檛 seem so easy though, because it has to be unset after the rendering finishes.

levitanong06:02:41

and putting the unsetting code in a setTimeout feels unsafe.

anmonteiro06:02:09

don't the lifecycle methods help you in that case?

levitanong06:02:59

oh right, I鈥檝e been putting them in the parser, but now it鈥檚 not necessary since i鈥檓 not touching the reconciler.

levitanong06:02:38

was wondering though, if (binding [om/*raf* (fn [f] (f))] (p/schedule-render! reconciler)) work

levitanong06:02:18

i realize, probably not.

sineer19:02:33

I've been experimenting with the "raf" npm lib and om inside a dev-om-card to implement a TimeLoop component and it works better than I expeced! I still don't fully understand how requestAnimationFrameworks works too I just copied an example from gl-react to build my om component...

sineer20:02:17

I too used react-set-state! to bypass om rendering loop but I ended up mutating the :timeloop/tick state that my components who need to animate based on tick are already querying that same :timeloop so maybe it's wrong to do it using requestAnimFrame. .? I would enjoy seeing some related code... 馃檪

levitanong20:02:49

request animation frame calls a function when the machine says it鈥檚 ready to render a new frame.

levitanong20:02:38

this allows the program to keep going without slowing down due to expensive render jobs

levitanong20:02:59

i.e. raf lets you tell the machine to do something only when it鈥檚 ready to.

sineer20:02:38

Yeah I understand that much but I'm still confused as to how it works with om next rendering loop. If I have a TimeLoop component that mutate say :tick and other components should do something when tick changes (possibly render) then the reconciler will triger rendering for the corresponding component by walking it's om-root... when I use om/react-set-state! and raf, I bypass that and only do that when the browser feels like it (based on free cpu and refresh rate etc..) ?

sineer20:02:34

It seems to be what my experiment have tought me 馃檪

sineer20:02:14

but I confused things a little and have the "raf" callback do an om/transact! on the timeloop :tick so that probably trigers the om-root rendering through om next as well I think...

sineer20:02:16

Here is my timeloop hack if you are curious: https://www.refheap.com/124988

sineer20:02:07

I think I need two kind of timeloop for my games... One like that using raf running at 30-60fps (if cpu can keep up) for my visual effects and one using core.async that run at steady 5-10 fps for my game logic.