export class StoreController { constructor(host, store, selector) { this.host = host this.store = store this.selector = selector host.addController(this) } hostConnected() { this._unsub = this.store.subscribe( (state) => { const next = this.selector(state) if (next !== this.value) { this.value = next this.host.requestUpdate() } } ) this.value = this.selector(this.store.getState()) } hostDisconnected() { this._unsub?.() } }