Skip to content

Fix observeOnce to unsubscribe properly#2140

Merged
compulim merged 4 commits intomicrosoft:masterfrom
compulim:fix-1872
Jul 4, 2019
Merged

Fix observeOnce to unsubscribe properly#2140
compulim merged 4 commits intomicrosoft:masterfrom
compulim:fix-1872

Conversation

@compulim
Copy link
Copy Markdown
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

() =>
new Promise((resolve, reject) => {
observable.subscribe(resolve, reject);
subscription = observable.subscribe(resolve, reject, resolve);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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