ReferenceStore
SnapshotController
Reactive controller for subscribing to a State container in HTML custom elements
Import
SnapshotController subscribes to a State container and triggers host updates when state changes. It has two overloads:
Full state – returns the entire state object. Re-renders on any state change.
With selector – returns a derived value from state. Re-renders only when the selected value changes (using shallow equality).
Use .track(state) to switch to a different State container at runtime.
SnapshotController vs StoreController
Both are reactive controllers, but they operate at different levels:
SnapshotController is lower-level. It works with State containers directly – the reactive primitives that back a store. Use it when building custom controllers or working outside the player store system.
StoreController is
higher-level. It resolves a store from a context or direct reference and
internally creates a SnapshotController when you pass a selector. Use it for
player UI elements.
Lifecycle
SnapshotController subscribes on hostConnected() and unsubscribes on hostDisconnected(). The React equivalent is useSnapshot.