UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

43 lines (42 loc) 1.73 kB
import { ReactivePlugin } from "../extras/reactive-plugin"; /** * Defines the signature for a function that creates a reactive proxy of a given object. * @template T The type of the object to make reactive. * @param value The underlying object. * @param reactiveOptions Optional configuration for the reactive instance. * @returns A reactive proxy of the input value. */ export type CreateReactive = <T>(value: T, reactiveOptions?: ReactiveOptions<T>) => T; /** * Options for configuring the behavior of reactive objects. * @template T The type of the object being made reactive (relevant for `reactiveList` and `nonReactiveList`). */ export type ReactiveOptions<T> = { /** * Name for the root of atoms. Helpful for debugging. By default, * it will equal to `ReactiveObject@${id}` where `id` is an number * increasing with every new reactive object */ name?: string; /** * Whether deeply nested objects, maps, sets, arrays, etc, become reactive. * @default true */ deep?: boolean; /** * A list of reactive plugins */ plugins?: ReactivePlugin[]; /** * A list of reactive properties. If provided, only these properties will become * reactive. Otherwise, all properties become reactive. Only applies to reactive objects * (not arrays, sets or maps) */ reactiveList?: Array<keyof T>; /** * A list of explicitly non-reactive properties. If provided, these properties will not become * reactive. Only applies to reactive objects (not arrays, sets or maps) */ nonReactiveList?: Array<keyof T>; }; export type ContextReactiveOptions = Omit<ReactiveOptions<Record<symbol | string | number, unknown>>, "name">;