mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { State } from "../../core/state.js";
|
|
import { Selector } from "../../core/shallow-equal.js";
|
|
import { ReactiveController, ReactiveControllerHost } from "@videojs/element";
|
|
//#region src/html/controllers/snapshot-controller.d.ts
|
|
type SnapshotControllerHost = ReactiveControllerHost & HTMLElement;
|
|
/**
|
|
* Subscribe to a `State<T>` container with optional selector.
|
|
*
|
|
* Without selector: returns full state, re-renders on any state change.
|
|
* With selector: returns selected slice, re-renders only when the slice changes (shallowEqual).
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* #state = new SnapshotController(this, sliderState, (s) => s.value);
|
|
* ```
|
|
*/
|
|
declare class SnapshotController<T extends object, R = T> implements ReactiveController {
|
|
#private;
|
|
/**
|
|
* @label Without Selector
|
|
* @param host - The host element that owns this controller.
|
|
* @param state - The State container to subscribe to.
|
|
*/
|
|
constructor(host: ReactiveControllerHost, state: State<T>);
|
|
/**
|
|
* @label With Selector
|
|
* @param host - The host element that owns this controller.
|
|
* @param state - The State container to subscribe to.
|
|
* @param selector - Derives a value from the state.
|
|
*/
|
|
constructor(host: ReactiveControllerHost, state: State<T>, selector: Selector<T, R>);
|
|
get value(): R;
|
|
/** Switch to tracking a different state container. */
|
|
track(state: State<T>): void;
|
|
hostConnected(): void;
|
|
hostDisconnected(): void;
|
|
}
|
|
declare namespace SnapshotController {
|
|
type Host = SnapshotControllerHost;
|
|
}
|
|
//#endregion
|
|
export { SnapshotController, SnapshotControllerHost };
|
|
//# sourceMappingURL=snapshot-controller.d.ts.map
|