UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

27 lines (26 loc) 1.91 kB
import { ReactiveChange } from "./reactive-plugin"; /** * Generates a list of change descriptions for an array set operation. * This function is intended to be called before the actual mutation occurs, * so `array` reflects the state *before* the change. * * @param array The reactive array proxy, reflecting state *before* the change. * @param inertArr The underlying inert array. * @param property The property being set (either a numeric index or the string 'length'). * @param previousValue For numeric `property`, the current value at that index. For 'length' `property`, the current length of the array. * @param nextValue For numeric `property`, the new value to be set at the index. For 'length' `property`, the new length to be set. * @param currentLength The length of `array` *before* the operation. * @returns An array of ReactiveChange objects, or null if no reportable changes occurred. */ export declare const getArraySetChanges: (array: unknown[], inertArr: unknown[], property: number | string | "length", previousValue: unknown, nextValue: unknown, currentLength: number) => ReactiveChange[] | null; /** * Generates a list of change descriptions for an array delete operation. * `delete array[index]` makes the property at `index` a "hole", and accessing it yields `undefined`. * The array length does not change. This is treated as setting the value at `index` to `undefined`. * * @param array The reactive array proxy, reflecting state *before* the change. * @param property The property being set (either a numeric index or the string 'length'). * @param previousValue The value at the `property` index *before* deletion. * @returns An array of ReactiveChange objects, or null if no reportable changes occurred. */ export declare const getArrayDeleteChanges: (array: unknown[], property: number | string | "length", previousValue: unknown) => ReactiveChange[] | null;