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

In Svelte >=3.6.9, when a writableDerived is set by its own subscribers, reflect does not receive the latest value #13

Closed
PixievoltNo1 opened this issue Nov 13, 2021 · 1 comment

Comments

@PixievoltNo1
Copy link
Owner

PixievoltNo1 commented Nov 13, 2021

Given code like this:

var store = writableDerived(writable(), () => 1, (reflecting) => {
	console.log(reflecting);
});
store.subscribe( (value) => {
	if (value.slice(-2) != "ho") {
		store.set(value + "ho");
	}
} );
store.set("hi");

You'll see "hi", not "hiho", logged to the console. This seems to be true for every Svelte version since 3.6.9, and every svelte-writable-derived version since 2.0.0. It appears to have been introduced by Svelte's fix for sveltejs/svelte#3191, so I don't think it's reasonable to ask Svelte to revert. This should get fixed on svelte-writable-derived's end, which may involve setting the minimum Svelte peerDependency version to 3.6.9.

(Incidentally, it should've been impossible to publish versions 2.1.0 and 2.1.1 with this bug. The test suite should've run using later Svelte versions, detected this problem, and prevented npm publish from proceeding. I have no idea what part of this process didn't work as advertised, but after recent changes I've verified it'll work in the future.)

@PixievoltNo1
Copy link
Owner Author

Fix released in version 2.1.2.

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

No branches or pull requests

1 participant