/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { ValueEqualityFn } from './equality'; import { ReactiveNode, SIGNAL } from './graph'; export type ComputationFn = (source: S, previous?: PreviousValue) => D; export type PreviousValue = { source: S; value: D; }; export interface LinkedSignalNode extends ReactiveNode { /** * Value of the source signal that was used to derive the computed value. */ sourceValue: S; /** * Current state value, or one of the sentinel values (`UNSET`, `COMPUTING`, * `ERROR`). */ value: D; /** * If `value` is `ERRORED`, the error caught from the last computation attempt which will * be re-thrown. */ error: unknown; /** * The source function represents reactive dependency based on which the linked state is reset. */ source: () => S; /** * The computation function which will produce a new value based on the source and, optionally - previous values. */ computation: ComputationFn; equal: ValueEqualityFn; } export type LinkedSignalGetter = (() => D) & { [SIGNAL]: LinkedSignalNode; }; export declare function createLinkedSignal(sourceFn: () => S, computationFn: ComputationFn, equalityFn?: ValueEqualityFn): LinkedSignalGetter; export declare function linkedSignalSetFn(node: LinkedSignalNode, newValue: D): void; export declare function linkedSignalUpdateFn(node: LinkedSignalNode, updater: (value: D) => D): void; export declare const LINKED_SIGNAL_NODE: Omit, 'computation' | 'source' | 'sourceValue'>;