UNPKG

@ablestack/rdo

Version:

A library to facilitate building and running graphs of Reactive Domain Objects - connecting JSON data sources to reactive client applications

53 lines 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RdoArrayNW = void 0; const logger_1 = require("../../infrastructure/logger"); const rdo_index_collection_nw_base_1 = require("../base/rdo-index-collection-nw-base"); const logger = logger_1.Logger.make('RdoArrayNW'); class RdoArrayNW extends rdo_index_collection_nw_base_1.RdoIndexCollectionNWBase { constructor({ value, typeInfo, key, mutableNodeCache, wrappedParentRdoNode, wrappedSourceNode, defaultEqualityComparer, syncChildNode, matchingNodeOptions, globalNodeOptions, targetedOptionMatchersArray, eventEmitter, }) { super({ typeInfo, key, mutableNodeCache, wrappedParentRdoNode, wrappedSourceNode, defaultEqualityComparer, syncChildNode, matchingNodeOptions, globalNodeOptions, targetedOptionMatchersArray, eventEmitter }); //------------------------------ // RdoIndexCollectionNWBase //------------------------------ this.onAdd = ({ index, key, newItem }) => { if (index === null || index === undefined) throw new Error('Index can not be null or undefined for index based collection operations'); this.value.splice(index, 0, newItem); return true; }; this.onReplace = ({ index, key, origItem, newItem }) => { if (index === null || index === undefined) throw new Error('Index can not be null or undefined for index based collection operations'); this.value.splice(index, 1, newItem); return true; }; this.onDelete = ({ index, key, origItem }) => { if (index === null || index === undefined) throw new Error('Index can not be null or undefined for index based collection operations'); this.value.splice(index, 1); return true; }; this._value = value; } //------------------------------ // IRdoNodeWrapper //------------------------------ get isLeafNode() { return false; } get value() { return this._value; } //------------------------------ // IRdoCollectionNodeWrapper //------------------------------ elements() { return this._value; } childElementCount() { return this._value.length; } } exports.RdoArrayNW = RdoArrayNW; //# sourceMappingURL=rdo-array-nw.js.map