joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to subscribe to individual values?

Jakobud opened this issue · comments

So this package takes all your preferences in a single persistent object. And whenever any value in your preferences gets updated, the entire object is changed and it triggers subscription events every place it's used. How do I set a subscription only on a single value and not the entire object?

What I'm thinking is that lets say you build a complicated web app, something with 100+ different settings and preferences that can be adjusted and stored. That means that your UI menus/windows in your app are going to have various HTML input controls to make those changes. And every single one of those HTML input components will be subscribed to your preferences object changing. And thus, anytime any single value in your preferences changes, it will trigger a subscription event on every single UI control, which could be hundreds depending on the complexity of the web app. I would think that would have a lot of opportunity to introduce some frontend lag.

Any thoughts on this? Is it possible to even subscribe to individual values?