UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

31 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.emitCache = emitCache; const builder_1 = require("@ng-doc/builder"); const operators_1 = require("rxjs/operators"); /** * Creates an RxJS operator that triggers the execution of cached emit functions. * This operator is designed to be used in an RxJS pipeline where caching mechanisms * are in place to temporarily store emit functions. Upon invocation, it iterates over * the `PENDING_CACHE`, executing each cached emit function. * * The `PENDING_CACHE` is expected to be a collection (e.g., array) of functions that * are intended to be executed to emit values or perform actions that were deferred. * * This operator does not alter the stream's data directly but performs side effects * (the execution of emit functions) that may influence the application's state or behavior. * @template T The type of items in the observable stream. * @returns An OperatorFunction<T, T> that maintains the stream's data type and performs * the side effect of executing cached emit functions. */ function emitCache() { return (source) => { return source.pipe((0, operators_1.tap)(() => { // Iterate over the PENDING_CACHE and execute each emit function builder_1.PENDING_CACHE.forEach((emitCache) => emitCache()); // Clear the PENDING_CACHE after all emit functions are executed builder_1.PENDING_CACHE.length = 0; })); }; } //# sourceMappingURL=emit-cache.js.map