SubscriptionController
Reactive controller that resolves a store and manages a derived subscription
Import
import { SubscriptionController } from "@videojs/store/html";Usage
Provide a store or store context plus functions that read the current value and subscribe to changes.
class QueueController {
readonly #tasks;
constructor(host, storeSource) {
this.#tasks = new SubscriptionController(host, storeSource, {
getValue: (store) => store.queue.tasks,
subscribe: (store, onChange) => store.queue.subscribe(onChange),
});
}
get value() {
return this.#tasks.value;
}
}The controller requests a host update when the subscription changes and unsubscribes when the host disconnects. Reading value throws until a store is available.
API Reference
Parameters
| Parameter | Type | Default | Details |
|---|---|---|---|
host* | object | — | |
| |||
source* | Store | Context<unknown, Store> | — | |
| |||
config* | function | — | |
| |||
Return Value
| Property | Type | Details |
|---|---|---|
value | Value | |
hostDisconnected | (() => void) |