Widdershin / cycle-restart

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

Cannot read property 'Time' of undefined #59

Closed wyqydsyq closed 7 years ago

wyqydsyq commented 7 years ago

Using cycle-restart with the latest @cycle/run (3.0.0) I get the following error upon initial load:

Uncaught TypeError: Cannot read property 'Time' of undefined
    at restart.js:154
    at restart.js:173
    at Object.options.path (index.ts:22)
    at __webpack_require__ (bootstrap 06d4da1…:659)
    at fn (bootstrap 06d4da1…:83)
    at Object.<anonymous> (process-update.js:132)
    at __webpack_require__ (bootstrap 06d4da1…:659)
    at bootstrap 06d4da1…:708
    at bootstrap 06d4da1…:708

Having a quick peek into the relevant source, I'm not sure how this code is even intended to work; the call to Cycle() returns the dispose method, but the code seems to be expecting an object with sources, sinks, and run properties: image

As you can see in this screenshot from the debugger, when looping over the Time driver everything seems to be undefined: image

wyqydsyq commented 7 years ago

So I just checked the Cycle Universal run package vs. the old @cycle/xstream-run this is built against and realized that it has a slightly different API now - the old default export constructor/factory type thing has been replaced with run() itself as the default export, and there's now another setup method to do that old one, padding this setup method instead of the default export of @cycle/run to my rerunner() call fixed this.

wyqydsyq commented 7 years ago

Closing this issue as it's not actually a bug, will submit a PR to update the documentation with examples that work with Cycle Universal :)