On this page
Separate changes and reaction
Use a separated listener to react on new store’s value, not an action function where you change this store.
function increase() { $counter.set($counter.get() + 1) printCounter(store.get())}
$counter.listen(counter => { printCounter(counter)})An action function is not the only way for store to a get new value. For instance, persistent store could get the new value from another browser tab.
With this separation your UI will be ready to any source of store’s changes.
Imported from the Nano Stores README for version 1.5.5. Improve this page there.