sapper icon indicating copy to clipboard operation
sapper copied to clipboard

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

Open AaronDDM opened this issue 4 years ago • 0 comments
trafficstars

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.

AaronDDM avatar Mar 23 '21 17:03 AaronDDM