The documentation at http://reactivex.io/documentation/operators/first.html is slightly wrong for the find operator, in rxjs at least. Documentation says that find emits undefined when no element matches. This is not correct, actually it just completes the observable.
The sample given:
var array = [1,2,3,4];
var source = Rx.Observable.fromArray(array)
.find(function (x, i, obs) {
return x === 5;
});
var subscription = source.subscribe(
function (x) { console.log('Next: ' + x); },
function (err) { console.log('Error: ' + err); },
function () { console.log('Completed'); });
outputs accordin to the documentation:
Next: undefined
Completed
but actually outputs:
Completed
Also see rxjs documentation for find: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/find.md
The documentation at http://reactivex.io/documentation/operators/first.html is slightly wrong for the find operator, in rxjs at least. Documentation says that find emits
undefinedwhen no element matches. This is not correct, actually it just completes the observable.The sample given:
outputs accordin to the documentation:
but actually outputs:
CompletedAlso see rxjs documentation for find: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/find.md