reactronic
Version:
Reactronic - Transactional Reactive State Management
30 lines (29 loc) • 893 B
JavaScript
const EMPTY_META = Object.freeze({});
export class Meta {
static get(obj, sym) {
return obj[sym];
}
static set(obj, sym, value) {
Object.defineProperty(obj, sym, { value, configurable: false, enumerable: false });
return obj;
}
static acquire(proto, sym) {
let meta = proto[sym];
if (!proto.hasOwnProperty(sym)) {
meta = Object.assign({}, meta);
Meta.set(proto, sym, meta);
}
return meta;
}
static getFrom(proto, sym) {
var _a;
return (_a = proto[sym]) !== null && _a !== void 0 ? _a : EMPTY_META;
}
}
Meta.Handle = Symbol("rx-handle");
Meta.Revision = Symbol("rx-revision");
Meta.Descriptor = Symbol("rx-descriptor");
Meta.Initial = Symbol("rx-initial");
Meta.Reactive = Symbol("rx-reactive");
Meta.Raw = Symbol("rx-raw");
Meta.Undefined = Symbol("rx-undefined");