UNPKG

@sustain/core

Version:

Sustain is a Framework that is barely used despedcies to make stable and sustainable apps

34 lines 945 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContext = exports.SustainContext = void 0; const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); class SustainContext { constructor() { this.subject = new rxjs_1.BehaviorSubject({}); this.context = {}; } set(key, value) { this.context[key] = value; this.subject.next({ action: key, value, }); } sub() { return this.subject; } get(key) { return this.context[key]; } on(key) { return this.subject.pipe(operators_1.filter((payload) => payload.action === key)); } } exports.SustainContext = SustainContext; const injectedContext = new SustainContext(); function getContext() { return injectedContext; } exports.getContext = getContext; //# sourceMappingURL=context.js.map