import { DepItem } from './_computed_queue'; import { Observable } from './observable'; import { ISubscribable, UseCB } from './subscribe'; /** * `PureComputed` is a variant of `Computed` suitable for use with a pure read function * (free of side-effects). A `PureComputed` is only subscribed to its dependencies when something is * subscribed to it. At other times, it is not subscribed to anything, and calls to `get()` will * recompute its value each time by calling its `read()` function. * * Its syntax and usage are otherwise exactly as for a `Computed`. * * In addition to being cheaper when unused, a `PureComputed` also avoids leaking memory when * unused (since it's not registered with dependencies), so it is not necessary to dispose it. */ export declare class PureComputed extends Observable { private _callback; private _write; private _sub; private readonly _dependencies; private _inCall; constructor(callback: (use: UseCB, ...args: any[]) => T, dependencies: ReadonlyArray); /** @internal */ _getDepItem(): DepItem; /** @override */ get(): T; /** * "Sets" the value of the pure computed by calling the write() callback if one was provided in * the constructor. Throws an error if there was no such callback (not a "writable" computed). * @param value - The value to pass to the write() callback. */ set(value: T): void; /** * Set callback to call when this.set(value) is called, to make it a writable computed. If not * set, attempting to write to this computed will throw an exception. */ onWrite(writeFunc: (value: T) => void): PureComputed; /** * Disposes the pureComputed, unsubscribing it from all observables it depends on. */ dispose(): void; private _activate; private _onListenerChange; private _read; } /** * Creates and returns a new PureComputed. The interface is identical to that of a Computed. */ export declare function pureComputed(cb: (use: UseCB) => T): PureComputed; export declare function pureComputed(a: Observable, cb: (use: UseCB, a: A) => T): PureComputed; export declare function pureComputed(a: Observable, b: Observable, cb: (use: UseCB, a: A, b: B) => T): PureComputed; export declare function pureComputed(a: Observable, b: Observable, c: Observable, cb: (use: UseCB, a: A, b: B, c: C) => T): PureComputed; export declare function pureComputed(a: Observable, b: Observable, c: Observable, d: Observable, cb: (use: UseCB, a: A, b: B, c: C, d: D) => T): PureComputed; export declare function pureComputed(a: Observable, b: Observable, c: Observable, d: Observable, e: Observable, cb: (use: UseCB, a: A, b: B, c: C, d: D, e: E) => T): PureComputed;