@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>
20 lines • 1.06 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.builderState = builderState;
const rxjs_1 = require("rxjs");
const types_1 = require("../types");
const stack_1 = require("./stack");
/**
* Operator function that transforms a source Observable into an Observable of BuilderState.
* It emits a BuilderPending state at the start, then a BuilderDone state when the source emits,
* and a BuilderError state if the source errors out.
* It also manages a global stack of pending builders.
* @param stage
* @param tag
* @template T The type of the source Observable.
* @returns {OperatorFunction<T, BuilderState<T>>} An OperatorFunction that can be used with pipe.
*/
function builderState(tag) {
return (source) => source.pipe((0, rxjs_1.map)((result) => new types_1.BuilderDone(tag, result)), (0, rxjs_1.startWith)(new types_1.BuilderPending(tag)), (0, rxjs_1.catchError)((error) => (0, rxjs_1.of)(new types_1.BuilderError(tag, [error]))), (0, stack_1.addToStack)(tag));
}
//# sourceMappingURL=builder-state.js.map
;