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

Fixing "Invalid" Error II #407

Merged

Conversation

josepot
Copy link
Contributor

@josepot josepot commented May 17, 2024

I probably did a bad job at explanning how shareReplay works, my apologies.

The thing is that every time that with shareReplay every time that its internal refCount goes down to zero, then it unsubscribes from the source.

Therefore, there must be a subscription always open for the observable to be "shared". This is because observables are not eager. What was happening is that every time the old code was performing a firstValueFrom that creates a subscription and when the condition is met (and the promise resolves) then it unsubscribes from the observable. Since that was its only subscription, then the refcount goes down to 0 and the observable dies. So, the next firstValueFrom creates a brand new subscription.

I realize that people coming from PJS may find Observables difficult to deal with. So, we will probably add an optional callback to the promise based functions so that you can introspect what's going on under the hood without having to learn how to work with observables.

@josepot josepot requested a review from a team as a code owner May 17, 2024 10:58
@josepot josepot force-pushed the fix/PolkadotActions-subscriptions branch from e8ff34b to 1d0baa7 Compare May 17, 2024 13:51
@mutantcornholio mutantcornholio merged commit 2f36243 into paritytech:main May 17, 2024
9 checks passed
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.

None yet

2 participants