Closed ronag closed 7 years ago
Yeah, this is indeed an issue. This is indeed as you stated, because RxJS's time based operators are hidden side effects.
I think you can get away with most operators assuming they take less than 500ms.
There needs to be a proper solution to this. Current workarounds include encapsulating time in a driver and basing everything off that (like Widdershin/cycle-animation-driver). I also wonder if we could somehow solve this problem by injecting a HistoricalScheduler into all of the time based drivers.
@Widdershin: https://github.com/dralletje/cycle-time-driver does solve some of the issues. However, there will be a lot of history to save and rerun when e.g. debouncing every 200ms...
True, although my tests have shown performance is a lot better than one might expect. Depending on how heavy your logic is it should be fine.
I am investigating checkpoints but that would require saving snapshots of an observable tree, something I am not sure is currently possible.
Also cycle-animation-driver is actually a time driver as well (animation is a function of time). It will probably run more smoothly than cycle-time-driver, as it uses requestAnimationFrame on the hood.
@ronag: as a longer term solution to this issue, @staltz and I discussed building a time driver into Cycle so that we can hook everything into that. It would also make testing Cycle apps that use time based operations like debounce much easier.
Here is my proposal for a solution: https://github.com/cyclejs/cyclejs/issues/380
And here is my implementation of a solution: https://github.com/cyclejs/time
With the xstream
version of cycle-restart
, if you use @cycle/time
you can use operators like debounce
and delay
they will work correctly.
If you use @cycle/time
you should be able to use the time based methods and have them work as expected when using cycle-restart
.
I'm going to close this, please reopen if you run into any trouble.
Does operators like
debounce
,throttle
and the like break hot reloading? These are kind of hidden side effects so I could understand if that is the case?I'm asking because I've had an issue where I had to move a
debounce
into a driver in order to have hot-reloading working again. Though I'm unsure whether this is because of some other bug?