Skip to content

Instantly share code, notes, and snippets.

@cburgdorf
Created March 6, 2012 08:01
Show Gist options
  • Save cburgdorf/1984825 to your computer and use it in GitHub Desktop.
Save cburgdorf/1984825 to your computer and use it in GitHub Desktop.
Rx bug?
var subject = new Rx.Subject();
var getObservable = function (eventName) {
return subject.asObservable()
.where(function (x) { return x.EventName === eventName; })
.takeUntil(function (x) { return x.Type === "onComplete"; })
.selectMany(function (x) {
return x.Type === "onNext" ? Rx.Observable.returnValue(x.Data) :
x.Type === "onError" ? Rx.Observable.throwException(x.Data) :
Rx.Observable.empty();
});
}
getObservable("SomethingHappened").subscribe(function(x){ console.log("onNext" + x); }, function(x){ console.log("onError" + x); }, function(){ console.log("onComplete");})
This throws:
TypeError: Object function (x) { return x.Type === "onComplete"; } has no method 'materialize'
as soon as I put in the takeUntil. If I leave it out, everything works as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment