UNPKG

@aimee-blue/ab-service-kit

Version:
38 lines (30 loc) 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromEventBus = fromEventBus; exports.pushToEventBus = pushToEventBus; exports.publishToEventBus = publishToEventBus; var _rxjs = require("rxjs"); var _operators = require("rxjs/operators"); var _operators2 = require("rxjs-spy/operators"); const subject = new _rxjs.Subject(); const sharedSubject = subject.asObservable().pipe((0, _operators2.tag)('event-bus'), (0, _operators.share)()); function fromEventBus() { return sharedSubject; } function pushToEventBus() { return stream => { return new _rxjs.Observable(subscriber => { subscriber.add(stream.subscribe({ next: data => subject.next(data), error: err => subscriber.error(err), complete: () => subscriber.complete() })); }); }; } function publishToEventBus(action) { subject.next(action); } //# sourceMappingURL=eventBus.js.map