-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
$store and store.subscribe behave differently #5520
Comments
This is expected. It's not that |
I've made a reproduction of the issue in a REPL, where using either the increment or the fetch buttons should switch a Using If I use This to me is very confusing and misleading, since I was expecting Thanks for the help... |
I just looked at the issue reproduction I had made and I now understand what I was doing wrong (I've learned the hard way when dealing with other similar issues): The order of the reactive statements is important. Doing $: loading2 = $loading;
$: {
value;
loading.fetch();
} is not the same as $: {
value;
loading.fetch();
}
$: loading2 = $loading; It seems obvious now that I understand it, but reactive assignments and statements seem so magical sometimes that it's easy to forget basic principles. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Describe the bug
Open console in this repl
in synchronous for loop
store.subscribe
runs callback for eachset
, while reactive$:
runs only on lastset
Expected behavior
Autosubscription and manual subscription should behave the same way or explained in documentation
Severity
Might broke some logic, if you expect all callback of
set
to run in autosubscription.I think this should be clarified in documentation.
The text was updated successfully, but these errors were encountered: