lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
35 lines (34 loc) • 1.16 kB
TypeScript
import { type Box } from './Box.js';
import { type ObservableCallback } from './ObservableCallback.js';
/**
* An aggregate helper class for widgets that contain a variable with a
* specified type which is intended to be controlled by the user.
*
* Useful for implementing widgets such as sliders, checkboxes, text input,
* etc...
*
* @typeParam V - The type of {@link Variable#value}.
*
* @category State Management
*/
export declare class Variable<V> implements Box<V> {
/** The current value, for internal use. */
private _value;
/** The function callbacks called when the value is changed */
private callbacks;
/**
* @param initialValue - The initial value of this variable. Sets {@link Variable#_value}.
*/
constructor(initialValue: V);
/**
* The current value.
*
* If setting, {@link Variable#setValue} is called with no group.
*/
get value(): V;
set value(value: V);
watch(callback: ObservableCallback<V>, callNow?: boolean, group?: unknown): this;
unwatch(callback: ObservableCallback<V>): this;
setValue(value: V, group?: unknown): boolean;
private doCallback;
}