UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

70 lines (67 loc) 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSetDeleteChanges = exports.getSetClearChanges = exports.getSetAddChanges = void 0; var _reactivePlugin = require("./reactive-plugin"); /** * Generates change descriptions for adding a value to a Set. * * @param set The reactive set proxy. * @param nextValue The value being added. This is the original value provided by the user. * @returns An array of ReactiveChange objects. */ const getSetAddChanges = (set, nextValue) => { const setChange = { type: _reactivePlugin.SetChangeType.AddValue, nextValue }; return [{ type: _reactivePlugin.ReactiveChangeType.Set, set, setChange }]; }; /** * Generates change descriptions for deleting a value from a Set. * * @param set The reactive set proxy. * @param previousValue The value being deleted. This is the original value provided by the user. * @returns An array of ReactiveChange objects. */ exports.getSetAddChanges = getSetAddChanges; const getSetDeleteChanges = (set, previousValue) => { const setChange = { type: _reactivePlugin.SetChangeType.DeleteValue, previousValue }; return [{ type: _reactivePlugin.ReactiveChangeType.Set, set, setChange }]; }; /** * Generates change descriptions for clearing a Set. * * @param set The reactive set proxy. * @param previousValues An array of all values (potentially reactive proxies) that were in the set before clearing. * @returns An array of ReactiveChange objects, or null if the set was already empty. */ exports.getSetDeleteChanges = getSetDeleteChanges; const getSetClearChanges = (set, previousValues) => { const changes = previousValues.map(previousValue => { const setChange = { type: _reactivePlugin.SetChangeType.DeleteValue, previousValue }; return { type: _reactivePlugin.ReactiveChangeType.Set, set, setChange }; }); return changes; }; exports.getSetClearChanges = getSetClearChanges; //# sourceMappingURL=reactive-plugin-set.js.map