Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Updates to the session store cause the page store subscription to fire. #1754

Open
AaronDDM opened this issue Mar 23, 2021 · 0 comments
Open

Comments

@AaronDDM
Copy link

Describe the bug
A clear and concise description of what the bug is.

Logs
N/A

To Reproduce
https://github.com/AaronDDM/sapper-store-update-bug/blob/main/src/routes/index.svelte

	import { stores } from "@sapper/app";
	const { session, page } = stores();
	page.subscribe((p) => {
		console.debug('[page.subscribe] called');
	})
	setTimeout(() => {
		session.update((s) => {
			console.debug('[session.update] called');
			return {...s}
		})
	})

Actual:
Console logs:

[session.update] called
[page.subscribe] called
[page.subscribe] called

Expected behaviour
Console logs:

[session.update] called
[page.subscribe] called

Severity
This has caused unexpected behaviour for us, but via some local caching of state we can avoid having our page.subscribe() code from being unnecessarily be called. It's not super urgent, but I think it should be fixed as soon as convenient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant