UNPKG

stencil-quantum

Version:

Experience the quantum realm of stencil.

43 lines (42 loc) 1.13 kB
import { React, Observe, Context, Provide } from "../context"; import { Implement } from "../context/implement"; // TODO: factory function that adds all keys to the config; export class Entanglement { constructor(schema, opts) { this.keys = Object.entries(schema) .map(([key, value]) => { var _a; return ({ name: key, namespace: (_a = opts === null || opts === void 0 ? void 0 : opts.namespace) !== null && _a !== void 0 ? _a : `$${Entanglement.uid++}`, default: value.default, mutable: value.mutable, debug: value.debug, config: this }); }) .reduce((a, b) => (Object.assign(Object.assign({}, a), { [b.name]: b })), {}); } get(key) { return this.keys[key]; } Provide(key) { return Provide(this, key); } Context(key) { return Context(this, key); } Observe(key) { return Observe(this, key); } React(key, target, targetKey) { return React(this, key, target, targetKey); } Implement(key) { return Implement(this, key); } Action(key) { return Context(this, key); } } Entanglement.uid = 0;