Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rxjs documentation for 'find' operator is wrong #319

Open
cmaart opened this issue Nov 7, 2016 · 1 comment
Open

Rxjs documentation for 'find' operator is wrong #319

cmaart opened this issue Nov 7, 2016 · 1 comment
Labels

Comments

@cmaart
Copy link

cmaart commented Nov 7, 2016

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

@cmaart cmaart added the RxJS label Nov 7, 2016
@akarnokd
Copy link
Member

akarnokd commented Jun 5, 2024

According to the most recent official docs, it is supposed to emit undefined:

https://rxjs.dev/api/index/function/find

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

No branches or pull requests

2 participants