Widdershin / cycle-restart

Swap out the code in your Cycle.js apps on the fly!
MIT License
123 stars 11 forks source link

Feature/memory stream error #66

Closed wyqydsyq closed 7 years ago

wyqydsyq commented 7 years ago

I was getting an error in my application because my DOM driver sink$ was somehow getting converted to a MemoryStream which caused an uncaught exception to be thrown by xstream when attempting to call lastSinkEvent$.imitate(sink$).

I noticed that lastSinkEvent$ is only ever actually used to figure out when to call shamefullySendNext() on filteredSink$ in situations where (isReplaying() && replayOnlyLastSink) so I tried wrapping the imitate in that same condition and it seems to work fine. I'm unsure of the actual use-case for replayOnlyLastSink so wasn't able to test it by hand but my changes haven't broken any tests.

wyqydsyq commented 7 years ago

@Widdershin the work-around you suggested to force sink$ back to a normal Stream when it's a MemoryStream instead of skipping the .imiate() altogether works well for me and seems less likely to introduce unintended side-effects than my previous commit.

Widdershin commented 7 years ago

I fixed up the test suite, just needed to check if sink$ was actually passed. Thanks for the contribution! 😄 I really appreciate all of your help.