Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Rx.Observable.prototype.timeout not working #969

Closed
jlVidal opened this issue Oct 13, 2015 · 3 comments
Closed

Rx.Observable.prototype.timeout not working #969

jlVidal opened this issue Oct 13, 2015 · 3 comments

Comments

@jlVidal
Copy link

jlVidal commented Oct 13, 2015

Hello,

I was playing with Rx, and this sample:

/* With no other */
var source = Rx.Observable
  .just(42)
  .delay(5000)
  .timeout(200);

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

Give me this error:
c:\node\ddp\node_modules\rx\dist\rx.time.js:853
subscription.setDisposable(other.subscribe(o));
^

TypeError: Cannot read property 'subscribe' of undefined
at c:\node\ddp\node_modules\rx\dist\rx.time.js:853:45
at schedule as _onTimeout
at Timer.listOnTimeout (timers.js:89:15)

Process finished with exit code 1

Node: v4.1.1
RxJs from npm: 4.0.4

@jlVidal
Copy link
Author

jlVidal commented Oct 13, 2015

To fix this error/exception on node.js I just need to change:

javascript
.timeout(200);


to

``` javascript``
 .timeout(200,Rx.Observable.empty());
//or better
.timeout(200, Rx.Observable.throw(new Rx.TimeoutError()));

I think is just a problem with the documentation and the samples provided on:
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/timeout.md

Thanks @Frikki for the help

mattpodwysocki added a commit that referenced this issue Oct 13, 2015
@mattpodwysocki
Copy link
Member

Fixed

@deanrad
Copy link

deanrad commented Aug 5, 2016

This has resurfaced - I have a JSBin which reproduces it here:
https://jsbin.com/yumeke

Using 4.1.0/rx.all.min.js and the RxJS sample code specified here:
http://reactivex.io/documentation/operators/subscribeon.html

/* Change from immediate scheduler to timeout */
var source = Rx.Observable.return(42, Rx.Scheduler.immediate)
    .subscribeOn(Rx.Scheduler.timeout);

var subscription = source.subscribe(
    function (x) { console.log('Next: ' + x); },
    function (err) { console.log('Error: ' + err); },
    function () { console.log('Completed'); });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants