type ListenerResult = { remove(): void; }; type UpdateCallback = (value: T) => void; type ReactiveValuesOf = { [key in keyof T]: ReactiveValue; }; /** * A `ReactiveValue` is a value that * - updates periodically, * - can fire listeners when it updates, * - and can be chanined together with other `ReactiveValue`s. * * A `ReactiveValue` is a read-only view. See {@link MutableReactiveValue} for a * read-write view. * * Static methods in the `ReactiveValue` and `MutableReactiveValue` classes are * constructors (e.g. `fromImmutable`). * * Avoid extending this class from an external library, as that may not be stable. */ export declare abstract class ReactiveValue { /** * Returns a reference to the current value of this `ReactiveValue`. * * The result of this **should not be modified** (use `setValue` instead). */ abstract get(): T; /** * Registers a listener that is notified when the value of this changes. */ abstract onUpdate(listener: UpdateCallback): ListenerResult; /** * Calls `callback` immediately, then registers `callback` as an onUpdateListener. * * @see {@link onUpdate}. */ abstract onUpdateAndNow(callback: UpdateCallback): ListenerResult; /** Returns a promise that resolves when this value is next changed. */ waitForNextUpdate(): Promise; /** Creates a `ReactiveValue` with an initial value, `initialValue`. */ static fromInitialValue(initialValue: T): MutableReactiveValue; /** Returns a `ReactiveValue` that is **known** will never change. */ static fromImmutable(value: T): ReactiveValue; /** * Creates a `ReactiveValue` whose values come from `callback`. * * `callback` is called whenever any of `sourceValues` are updated and initially to * set the initial value of the result. */ static fromCallback(callback: () => T, sourceValues: ReactiveValue[]): ReactiveValue; /** * Returns a reactive value derived from a single `source`. * * If `inverseMap` is `undefined`, the result is a read-only view. */ static map(source: ReactiveValue, map: (a: A) => B, inverseMap?: undefined): ReactiveValue; /** * Returns a reactive value derived from a single `source`. */ static map(source: ReactiveValue, map: (a: A) => B, inverseMap: (b: B) => A): MutableReactiveValue; static union(values: ReactiveValuesOf): ReactiveValue; } export declare abstract class MutableReactiveValue extends ReactiveValue { /** * Changes the value of this and, if different, fires all update listeners. * * @see {@link onUpdate} */ abstract set(newValue: T): void; static fromProperty(sourceValue: MutableReactiveValue, propertyName: Name): MutableReactiveValue; } export default ReactiveValue;