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

.find() does not returns undefinied if unfound #939

Closed
manuelfc1 opened this issue Sep 29, 2015 · 4 comments
Closed

.find() does not returns undefinied if unfound #939

manuelfc1 opened this issue Sep 29, 2015 · 4 comments

Comments

@manuelfc1
Copy link

Trying the example from the docs:

    var array = [1, 2, 3, 4];

        var source = Rx.Observable.from(array)
            .find(function(x, i, obs) { return x === 5; });

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

it does not log "undefined" as expected

@paulpdaniels
Copy link
Contributor

@manuelfc1 Looks like the docs are wrong here, per this commit 86787f8, find was fixed so that if no value is found it should just complete. I'm guessing this was changed because it is difficult to tell if the sequence is empty or you are just returning undefined.

But we should probably fix the docs either way.

@mattpodwysocki
Copy link
Member

@manuelfc1 documentation fix coming, yes it defaults to onCompleted now if not found, not undefined.

@manuelfc1
Copy link
Author

A CHANGELOG would be also appreciated :)

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

@manuelfc1 document fix 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