UNPKG

@connectv/core

Version:

agent-based reactive programming library for typescript/javascript

33 lines 1.15 kB
import { SimpleDeep } from "./simple-deep"; import { KeyedDeep } from "./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 * */ export function deep(state, key) { if (key) return new KeyedDeep(state, key); else return new SimpleDeep(state); } /** * * 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 * */ export function keyed(keyfunc) { return (accessor, compare) => new KeyedDeep(accessor, keyfunc, compare); } export default deep; //# sourceMappingURL=deep.js.map