UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

39 lines (38 loc) 1.72 kB
import { ReactiveLayer } from "./reactive-primitive-types"; /** * Provides the fundamental reactive layer for fluidstate. * This function must be called once before any other fluidstate reactive * functionalities are used. * * @param layer - An object conforming to the ReactiveLayer interface, * which will be used for all underlying reactive operations. * @throws Error if the reactive layer has already been provided. */ export declare const provideReactiveLayer: (layer: ReactiveLayer) => void; /** * Unsafely replaces the existing reactive layer with a new one. There * are predictable and unpredictable consequences of doing this. One of the * issues will be that past reactions cannot observe new reactive objects * and vice versa. * * @param layer - An object conforming to the ReactiveLayer interface, * which will be used for all underlying reactive operations, or * `null` in order to unset the layer. */ export declare const unsafeReplaceReactiveLayer: (layer: ReactiveLayer | null) => void; /** * Retrieves the fundamental reactive layer that was previously set * via `provideReactiveLayer`. * * This function is primarily for internal use within fluidstate or by * extensions that need direct access to the underlying reactive primitives. * * @returns The reactive layer instance. * @throws Error if `provideReactiveLayer` has not been called yet. */ export declare const getReactiveLayer: () => ReactiveLayer; /** * @returns The fundamental reactive layer that was previously set via * `provideReactiveLayer` or `null` if it was not provided. */ export declare const getCurrentReactiveLayer: () => ReactiveLayer | null;