Fork me on GitHub

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


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


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


@mikethompson Yes, I think that’s it


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)?


when you use dispatch, that is


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


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


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


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


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


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


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


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