-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(subscriber): makes sure default callbacks are provided
default callbacks should be provided both - when given a subscriber object and also when given separate callback functions. Default error callback should re-throw the error BREAKING CHANGE: default callbacks are now provided both - when given a subscriber object and also when given separate callback functions. Also default error callback now re-throws the error instead of th rowing a new Error()
- Loading branch information
Showing
2 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
export const Subscriber = (nextOrSubscriber, error, complete) => | ||
typeof nextOrSubscriber === 'object' | ||
? nextOrSubscriber | ||
: { | ||
next: nextOrSubscriber, | ||
error: error || (() => {throw new Error()}), | ||
complete: complete || (() => {}) | ||
} | ||
export const Subscriber = (nextOrSubscriber, error, complete) => { | ||
if (typeof nextOrSubscriber === 'object') { | ||
nextOrSubscriber.error = nextOrSubscriber.error || (err => {throw err}) | ||
nextOrSubscriber.complete = nextOrSubscriber.complete || (() => {}) | ||
return nextOrSubscriber | ||
} | ||
|
||
return { | ||
next: nextOrSubscriber, | ||
error: error || (err => {throw err}), | ||
complete: complete || (() => {}) | ||
} | ||
} |