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

Align single() interface to last() to allow emit default value? #323

Closed
kwonoj opened this issue Sep 16, 2015 · 2 comments
Closed

Align single() interface to last() to allow emit default value? #323

kwonoj opened this issue Sep 16, 2015 · 2 comments

Comments

@kwonoj
Copy link
Member

kwonoj commented Sep 16, 2015

In case of last operator, it's allows to specify default value if there isn't any matching element.

Rx.Observable.prototype.last([predicate], [thisArg], [defaultValue])

single does similar jobs as operator that returns first matching element instead of last, but it does not allows to specify default value as

Rx.Observable.prototype.single(predicate, [thisArg])

so if there isn't any matching element only undefined will be emitted.

Maybe it'd be better to align single also can accept default value?
Initial PR mimics existing behavior (do not accept default value) is created at #322

@kwonoj
Copy link
Member Author

kwonoj commented Sep 16, 2015

At second thought, feeling it may be better to leave single as is since first does jobs for default value and single specifically guarantees if there is only single matching element. Leave issue opened to get clarification for now.

@benlesh
Copy link
Member

benlesh commented Sep 18, 2015

I'm closing this for now, as I think when it was asked, there was some confusion about the behavior of single.

@benlesh benlesh closed this as completed Sep 18, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
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

2 participants