UNPKG

@codianz/rx

Version:
82 lines 2.99 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.emitIfExists = exports.peep = exports.readySetGo = exports.doSubscribe = void 0; var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); var utils = __importStar(require("@codianz/utils")); var log_index = 0; function doSubscribe(log, s, o) { var index = ++log_index; log.debug("[" + s + ":#" + index + "] start subscribe"); o.subscribe({ next: function (j) { log.debug("[" + s + ":#" + index + "] on next\n" + utils.string.anyToString(j)); }, error: function (err) { log.debug("[" + s + ":#" + index + "] on error\n" + utils.string.anyToString(err)); }, complete: function () { log.debug("[" + s + ":#" + index + "] on completed"); } }); } exports.doSubscribe = doSubscribe; function readySetGo(ready, observable) { return new rxjs_1.Observable(function (observer) { observable.subscribe({ next: function (v) { observer.next(v); }, error: function (err) { observer.error(err); }, complete: function () { observer.complete(); } }); ready(); }); } exports.readySetGo = readySetGo; var peep_index = 0; function peep(log, s) { var index = ++peep_index; return operators_1.tap({ next: function (j) { log.debug("[" + s + ":#" + index + "] on next\n" + utils.string.anyToString(j)); }, error: function (err) { log.debug("[" + s + ":#" + index + "] on error\n" + utils.string.anyToString(err)); }, complete: function () { log.debug("[" + s + ":#" + index + "] on completed"); } }); } exports.peep = peep; function emitIfExists() { return operators_1.mergeMap(function (v) { return v ? rxjs_1.of(v) : rxjs_1.NEVER; }); } exports.emitIfExists = emitIfExists; //# sourceMappingURL=rx.js.map