-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(throwIfEmpty): adds throwIfEmpty operator #3368
Conversation
Having this operator basically means that
|
This is a new, simple, operator that will emit an error if the source observable completes without emitting a value. This primitive operator can be used to compose other operators such as `first` and `last`, and is a good compliment for `defaultIfEmpty`.
da97e77
to
cc060c7
Compare
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change.
* | ||
* @example | ||
* | ||
* const click$ = fromEvent(button, 'clicks'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click
*/ | ||
export const throwIfEmpty = | ||
<T>(errorFactory: (() => any) = defaultErrorFactory) => tap<T>({ | ||
hasValue: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL this works
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is a new, simple, operator that will emit an error if the source observable completes without emitting a value. This primitive operator can be used to compose other operators such as
first
andlast
, and is a good compliment fordefaultIfEmpty
.This is a step toward refactoring a few other operators to be smaller.