-
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
fix: useDeprecatedSynchronousErrorThrowing honored for flattened sync sources #5984
Merged
benlesh
merged 1 commit into
ReactiveX:master
from
benlesh:fix/5983-moar-super-gross-mode-fun
Jan 26, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -132,46 +132,40 @@ export class SafeSubscriber<T> extends Subscriber<T> { | |
) { | ||
super(); | ||
|
||
// If we don't have arguments, or the observer passed is already EMPTY_OBSERVER, | ||
// use EMPTY_OBSERVER. This is just to save a little on object allocations. | ||
this.destination = EMPTY_OBSERVER; | ||
if ((observerOrNext || error || complete) && observerOrNext !== EMPTY_OBSERVER) { | ||
// We've got either functions or an observer to deal with | ||
// let's figure that out here. | ||
|
||
let next: ((value: T) => void) | undefined; | ||
if (isFunction(observerOrNext)) { | ||
next = observerOrNext; | ||
} else if (observerOrNext) { | ||
// Even if it's an observer, we have to pull the handlers off and | ||
// capture the owner object as the context. That is because we're | ||
// going to put them all in a new destination with ensured methods | ||
// for `next`, `error`, and `complete`. That's part of what makes this | ||
// the "Safe" Subscriber. | ||
({ next, error, complete } = observerOrNext); | ||
let context: any; | ||
if (this && config.useDeprecatedNextContext) { | ||
// This is a deprecated path that made `this.unsubscribe()` available in | ||
// next handler functions passed to subscribe. This only exists behind a flag | ||
// now, as it is *very* slow. | ||
context = Object.create(observerOrNext); | ||
context.unsubscribe = () => this.unsubscribe(); | ||
} else { | ||
context = observerOrNext; | ||
} | ||
next = next?.bind(context); | ||
error = error?.bind(context); | ||
complete = complete?.bind(context); | ||
let next: ((value: T) => void) | undefined; | ||
if (isFunction(observerOrNext)) { | ||
// The first argument is a function, not an observer. The next | ||
// two arguments *could* be observers, or they could be empty. | ||
next = observerOrNext; | ||
} else if (observerOrNext) { | ||
// The first argument is an observer object, we have to pull the handlers | ||
// off and capture the owner object as the context. That is because we're | ||
// going to put them all in a new destination with ensured methods | ||
// for `next`, `error`, and `complete`. That's part of what makes this | ||
// the "Safe" Subscriber. | ||
({ next, error, complete } = observerOrNext); | ||
let context: any; | ||
if (this && config.useDeprecatedNextContext) { | ||
// This is a deprecated path that made `this.unsubscribe()` available in | ||
// next handler functions passed to subscribe. This only exists behind a flag | ||
// now, as it is *very* slow. | ||
context = Object.create(observerOrNext); | ||
context.unsubscribe = () => this.unsubscribe(); | ||
} else { | ||
context = observerOrNext; | ||
} | ||
|
||
// Once we set the destination, the superclass `Subscriber` will | ||
// do it's magic in the `_next`, `_error`, and `_complete` methods. | ||
this.destination = { | ||
next: next ? maybeWrapForDeprecatedSyncErrorHandling(next, this) : noop, | ||
error: error ? maybeWrapForDeprecatedSyncErrorHandling(error, this) : defaultErrorHandler, | ||
complete: complete ? maybeWrapForDeprecatedSyncErrorHandling(complete, this) : noop, | ||
}; | ||
next = next?.bind(context); | ||
error = error?.bind(context); | ||
complete = complete?.bind(context); | ||
} | ||
|
||
// Once we set the destination, the superclass `Subscriber` will | ||
// do it's magic in the `_next`, `_error`, and `_complete` methods. | ||
this.destination = { | ||
next: next ? maybeWrapForDeprecatedSyncErrorHandling(next, this) : noop, | ||
error: maybeWrapForDeprecatedSyncErrorHandling(error ? error : defaultErrorHandler, this), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The meat of the change is here. |
||
complete: complete ? maybeWrapForDeprecatedSyncErrorHandling(complete, this) : noop, | ||
}; | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
After some thought, I realized that this check, and setting
this.destination = EMPTY_OBSERVER
was pointless, so that got removed.It might be better to review this with "ignore whitespace" on.