Fork me on GitHub
#re-frame
<
2017-09-15
>
danielcompton00:09:58

@jfntn not at the moment, what's the use case? How would you handle cleaning up the subscription instead? Would it be manual?

jfntn15:09:13

So we were running into a perf issue with a side-effectful sub that triggers a long-running backend call. That sub is used in a “details” kind of component that’d get unmounted and remounted causing the side-effect to fire-off everytime, eventhough the data fetched is sort of global. Our fix for now is to cache it forever, by adding a timeout fn that clears the on-dispose-arr

danielcompton22:09:18

Good use case, open up an issue so we can keep track of it

borkdude06:09:15

@mikethompson Yes, I think that’s it

reefersleep08:09:06

So, @borkdude, the explanation that you don’t see the optimistic update is perhaps because it does not come into effect before the actual update happens (after triggering a different event, a http request and so on)?

reefersleep08:09:17

when you use dispatch, that is

reefersleep08:09:34

because the event is parked on a queue along with other events, and perhaps only enacted upon in the next 16ms cycle

reefersleep08:09:57

and the http-chain is fast enough to complete its roundtrip within your current 16ms cycle

reefersleep08:09:26

I realize I’m inadvertently rewording some stuff that @mikethompson already said 🙂 I think a whiteboard would be nice right about now!

reefersleep08:09:48

@mikethompson and I are hampered by not seeing your app in action and not knowing details of your event chain, but if you find that this explanation makes sense, I’ll chalk this down as a victory for us all and make a note of it for when I have to use reg-event-fx myself 😄

borkdude08:09:04

@reefersleep Thanks for thinking along, I think it has to do with refresh cycles/animation frames and this is why dispatch-sync solves it. For now, consider it solved, I’m already working on other parts.

borkdude08:09:45

If I bump into similar problems, I’ll extract a sample app from it for reproduction

reefersleep08:09:19

I’m generally on thin ice when it comes to asynchronous stuff, and with its internal handling of asynchronous events, re-frame adds another black-box aspect to the mix from my perspective

reefersleep08:09:10

In my case, it might just be solved by reading up on re-frame‘s docs/docstrings