@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
37 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var simple_deep_1 = require("./simple-deep");
var keyed_deep_1 = require("./keyed-deep");
/**
*
* Creates a [deep state](https://connective.dev/docs/deep) from given state.
* You can track indexes, properties and keyed entities on deep states as bound
* reactive states.
* [Checkout the docs](https://connective.dev/docs/deep) for examples and further information.
*
* @param state the state to be used as the basis of the returned deep state
* @param key the key function to be used to track entities in the deep state
*
*/
function deep(state, key) {
if (key)
return new keyed_deep_1.KeyedDeep(state, key);
else
return new simple_deep_1.SimpleDeep(state);
}
exports.deep = deep;
/**
*
* Returns a deep child factory that creates [keyed deep](https://connective.dev/docs/deep#keyed-deep) sub-states
* with given key function. Pass this to `.sub()` or `.key()` on [deep states](https://connective.dev/docs/deep)
* to have keyed sub-states.
*
* @param keyfunc the key function to be used
*
*/
function keyed(keyfunc) {
return function (accessor, compare) { return new keyed_deep_1.KeyedDeep(accessor, keyfunc, compare); };
}
exports.keyed = keyed;
exports.default = deep;
//# sourceMappingURL=deep.js.map