UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

89 lines (86 loc) 3.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.beforeChange = exports.afterChange = exports.SetChangeType = exports.ReactiveChangeType = exports.ObjectChangeType = exports.MapChangeType = exports.ArrayChangeType = void 0; /** * Defines the structure for a reactive plugin, which can hook into the lifecycle * of changes within reactive objects. * Plugins can execute custom logic before and/or after changes are applied. */ const beforeChange = (changes, plugins) => { plugins?.forEach(plugin => plugin.beforeChange?.(changes)); }; exports.beforeChange = beforeChange; const afterChange = (changes, plugins) => { plugins?.forEach(plugin => plugin.afterChange?.(changes)); }; /** * Enumerates the types of reactive data structures that can undergo changes * tracked by reactive plugins. */ exports.afterChange = afterChange; let ReactiveChangeType; /** * Represents a discriminated union of all possible change types that can occur * in different reactive data structures (Array, Map, Set, Object). * Each change object includes the type of the reactive structure, a reference to it, * and the specific change details. */ exports.ReactiveChangeType = ReactiveChangeType; (function (ReactiveChangeType) { ReactiveChangeType[ReactiveChangeType["Array"] = 0] = "Array"; ReactiveChangeType[ReactiveChangeType["Set"] = 1] = "Set"; ReactiveChangeType[ReactiveChangeType["Map"] = 2] = "Map"; ReactiveChangeType[ReactiveChangeType["Object"] = 3] = "Object"; })(ReactiveChangeType || (exports.ReactiveChangeType = ReactiveChangeType = {})); /** * Enumerates the types of modifications that can occur within a reactive array. */ let ArrayChangeType; /** * Represents a discriminated union of specific changes that can happen to a reactive array. */ exports.ArrayChangeType = ArrayChangeType; (function (ArrayChangeType) { ArrayChangeType[ArrayChangeType["PushValue"] = 0] = "PushValue"; ArrayChangeType[ArrayChangeType["SetValue"] = 1] = "SetValue"; ArrayChangeType[ArrayChangeType["PopValue"] = 2] = "PopValue"; })(ArrayChangeType || (exports.ArrayChangeType = ArrayChangeType = {})); /** * Enumerates the types of modifications that can occur within a reactive map. */ let MapChangeType; /** * Represents a discriminated union of specific changes that can happen to a reactive map. */ exports.MapChangeType = MapChangeType; (function (MapChangeType) { MapChangeType[MapChangeType["SetValue"] = 0] = "SetValue"; MapChangeType[MapChangeType["DeleteValue"] = 1] = "DeleteValue"; })(MapChangeType || (exports.MapChangeType = MapChangeType = {})); /** * Enumerates the types of modifications that can occur within a reactive set. */ let SetChangeType; /** * Represents a discriminated union of specific changes that can happen to a reactive set. */ exports.SetChangeType = SetChangeType; (function (SetChangeType) { SetChangeType[SetChangeType["AddValue"] = 0] = "AddValue"; SetChangeType[SetChangeType["DeleteValue"] = 1] = "DeleteValue"; })(SetChangeType || (exports.SetChangeType = SetChangeType = {})); /** * Enumerates the types of modifications that can occur on the properties of a reactive object. */ let ObjectChangeType; /** * Represents a discriminated union of specific changes that can happen to the properties of a reactive object. */ exports.ObjectChangeType = ObjectChangeType; (function (ObjectChangeType) { ObjectChangeType[ObjectChangeType["SetProperty"] = 0] = "SetProperty"; ObjectChangeType[ObjectChangeType["DeleteProperty"] = 1] = "DeleteProperty"; })(ObjectChangeType || (exports.ObjectChangeType = ObjectChangeType = {})); //# sourceMappingURL=reactive-plugin.js.map