vUX / Store / v4.1.0
The badge, the product cards, the cart and the totals below are four separate components. None of them calls another. They all follow one Store, and a single set() moves every one that cares.
Watch the pill: set() returns the fields that actually changed, computed ones
included. Pick the currency that is already selected and it returns nothing, so nobody is told.
A subscriber names the fields it follows. A change reaches it only when one of those
fields moved, and changed lists only those. Tick the boxes to change what
each one watches (it re-subscribes), then fire the buttons.
The fourth subscriber watches sum, a computed field. It hears a and
b changes through it, never c.
Ten separate set() calls tell subscribers ten times. Inside batch()
the store changes at once (a get() inside sees every step), but subscribers are
told once, with every field that moved.
Subscriber A converts celsius into fahrenheit with its own
set(). That change is queued, not announced mid-round, so B still hears
the first change with the state A was given. A second round then announces
fahrenheit. The last button wires a subscriber that never settles, and the store
stops it after 100 rounds.
bind() runs its select once at once, then on each change to the
fields it watches. Destroy the widget and its binding drops on the next change instead of
throwing. The log counts every select run, so you can see it stop.
set({ other }) changes a field the binding does not watch, so select
does not run at all. That is what the fields argument buys.
Every button below really misuses the API. The text is the Error exactly as
thrown, and none of these calls changes the store.
pick a case