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

feat(throwError): now accepts a factory to create the error #5647

Merged

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Aug 16, 2020

  • Adds feature to allow the error instance the consumer is notified with to be created at the moment of notification.
  • Updates tests to use "run mode".
  • Improves documentation, including recommendations on when throwError is not necessary.

BREAKING CHANGE: In an extreme corner case for usage, throwError is no longer able to emit a function as an error directly. If you need to push a function as an error, you will have to use the factory function to return the function like so: throwError(() => functionToEmit), in other words throwError(() => () => console.log('called later')).

resolves #5617

- Adds feature to allow the error instance the consumer is notified with to be created at the moment of notification.
- Updates tests to use "run mode".
- Improves documentation, including recommendations on when `throwError` is not necessary.

BREAKING CHANGE: In an extreme corner case for usage, `throwError` is no longer able to emit a function as an error directly. If you need to push a function as an error, you will have to use the factory function to return the function like so: `throwError(() => functionToEmit)`, in other words `throwError(() => () => console.log('called later'))`.

resolves ReactiveX#5617
@benlesh benlesh requested a review from cartant August 16, 2020 02:08
Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One nitpick comment.

src/internal/observable/throwError.ts Outdated Show resolved Hide resolved
@benlesh benlesh merged commit dad270a into ReactiveX:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: allow throwError to accept a factory function
2 participants