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

Diamond store dependencies #2660

Closed
zmitry opened this issue May 2, 2019 · 2 comments
Closed

Diamond store dependencies #2660

zmitry opened this issue May 2, 2019 · 2 comments

Comments

@zmitry
Copy link

zmitry commented May 2, 2019

component: svelte/store;
issue: diamond dependencies for derived values
repl: https://svelte.dev/repl?version=3.1.0&gist=0f3250ae87011dc9a91e8e4ab8ddd6f9

For diamond dependencies you have issue with unnecessary updates which affects to useless component rerendering or unnecessary computations.
You can solve this issue with approach similar to mobx https://github.com/mobxjs/mobx/blob/a5cb65926621266716f8d11d716bf337e60dc3c1/src/core/observable.ts#L136
Or I think it's doable with topological ordering of stores. The issue with that stores might be created at runtime and even from js files.

@Conduitry
Copy link
Member

I think this is something that's niche enough that we don't want to make the existing store implementations bigger by supporting it, nor do we want to make the API surface more confusing by adding a separate implementation that does something like this. If someone needs this sort of thing, they can implement it themselves - thanks to the simple store contract, Svelte can easily subscribe to stores that aren't based on any of its built-in stores.

@TehShrike
Copy link
Member

@zmitry you may be interested in https://github.com/TehShrike/warg/ which solves the problem in a similar way to mobx, and is a valid Svelte store.

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

3 participants