RxJs V2.0.20327 Beta Bug - startWith(undefined) throws exception
-
18 Mei 2012 17:58
startWith() crashes if first argument is undefined:
QUnit.test("RxJs 2.0 Beta Bug: startWith() does not crash if first argument is undefined", 1, function () { Rx.Observable.empty().startWith(undefined, 1); QUnit.ok(true, "no error"); });
Crashes with this error:Cannot read property 'now' of undefined - {} (+9ms)
Also...the function seems to accept an optional Scheduler first argument. Could the vsdoc be updated to mention that?
Thanks!
Semua Balasan
-
19 Mei 2012 3:15
Yes, I'll update the documentation. It's getting confused because it thinks the undefined is the scheduler. Is it your intention to pass in undefined as an actual value to this function?
Matt
-
21 Mei 2012 15:57
Yes, the code was more complicated than the above, but basically undefined was one of the values I was passing through the observable. I fixed my copy by just changing the "arguments[0]!==null" to "arguments[0]!=null" inside startWith(). But it occurs to me that it will still cause problems if my value actually has a "now" member (Dates for example). Seems like the only safe way is to use instanceOf Rx.Scheduler, which may or may not be possible depending on how you created the various schedulers.
I suppose it is not the end of the world to keep the simple duck typing mechanism you have now--now that I know I can supply a scheduler as the first argument, I can avoid the problem by always supplying a scheduler.
Thanks!
- Diedit oleh bman654 21 Mei 2012 15:58 typo