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

Fix observeOnce to unsubscribe properly #2140

Merged
merged 4 commits into from
Jul 4, 2019
Merged

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Jul 2, 2019

Fixes #1872.

Changelog Entry

Description

Our observeOnce saga effect does not unsubscribe itself from the observable. New code added to unsubscribe after first onNext, onError, or onCompleted.

Specific Changes

Modified packages/core/src/sagas/effects/observeOnce.js to unsubscribe regardless of conditions.


  • Testing Added

@@ -8,13 +8,11 @@ export default function observeOnceEffect(observable) {
return yield call(
() =>
new Promise((resolve, reject) => {
observable.subscribe(resolve, reject);
subscription = observable.subscribe(resolve, reject, resolve);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why next and complete are the same? to me it seems like this would make resolve be called twice. :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

observeOnce is essentially converting a stream into an async binary operation (success or fail in async fashion, more-or-less Promise).

For "complete without any results", I think it should be considered as "positive with result of undefined".

Copy link
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

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

Approved, but it looks like build is failing. I also asked a question for knowledge purposes, not as constructive criticism xD

@compulim compulim merged commit aaed837 into microsoft:master Jul 4, 2019
@compulim compulim deleted the fix-1872 branch July 4, 2019 01:32
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.

observeOnce did not unsubscribe correctly
2 participants