import { Emitter } from './emitter'; type Resolved = [T] extends [never] ? M : T; /** * A class that holds a value and watches it for changes (deeply by default). * * An Observable can be constructed with a default value like this: * * ```ts * const myVariable = new Observable(false); * ``` * * Observable will automatically infer the type from the default value. You may also specify the type using the first template parameter: * * ```ts * const myVariable = new Observable(false); * ``` * * The value of the Observable may be accessed and changed using the `value` parameter: * ```ts * console.log(myVariable.value); * * myVariable.value = 4; * ``` * * Setting `value` to `undefined` restores the value to the default specified in the constructor. * * A function can be registered to receive changes to the value (or any of its recursive descendent keys or elements): * ```ts * const myVariable = new Observable(false, newValue => console.log(newValue)); * ``` * * @typeParam Type - The type of the contained value * @typeParam TypeInternal - An internal type used to improve automatic type detection */ export declare class Observable extends Emitter<[Resolved]> { private _deep; private _proxies; private _value; private _default; /** * Constructs a new Observable * * @param def - The default (and initial) value of the Observable. * @param withHandler - A function that will be called when the value (or any of its recursive descendent keys or elements) is changed * @param deep - Set to false to only track changes to the top level `value` itself (and not any of its descendent keys or elements) */ constructor(def: TypeInternal, withHandler?: (v: TypeInternal) => void, deep?: boolean, callWithImmediately?: boolean); constructor(def: Type, withHandler?: (v: Type) => void, deep?: boolean, callWithImmediately?: boolean); /** * Access the current value for this Observable. Changing this value (or, unless deep inspection is disabled, its recursive elements and keys) will trigger any registered handlers to be called with the new value. * * Setting `value` to `undefined` will restore the value to the default specified in the constructor. */ get value(): Resolved; private _wrap; set value(v: Resolved | undefined); addListener(fn: (v: Resolved) => void, priority?: number, callImmediately?: boolean): void; private _emitValue; setValueAtPath(path: (string | number)[], val: any): void; getValueAtPath(path: (string | number)[]): any; } export {};