UNPKG

@lifaon/rx-js-light

Version:

Blazing fast Observables

37 lines (36 loc) 880 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createUnicastSource = void 0; var freeze_1 = require("../../../../../misc/helpers/freeze.cjs"); function createUnicastSource() { var _emitFunction = null; var emit = function (value) { if (_emitFunction !== null) { _emitFunction(value); } }; var subscribe = function (emit) { if (_emitFunction === null) { var running_1 = true; _emitFunction = emit; return function () { if (running_1) { running_1 = false; _emitFunction = null; } }; } else { throw new Error("Max one observer allowed"); } }; return (0, freeze_1.freeze)({ getObserver: function () { return _emitFunction; }, emit: emit, subscribe: subscribe }); } exports.createUnicastSource = createUnicastSource;