1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var rxjs_1 = require("rxjs");
|
4 | var operators_1 = require("rxjs/operators");
|
5 | /**
|
6 | * Determines the unwrapping behavior of asynchronous resolve values.
|
7 | *
|
8 | * - When an Observable is returned from the resolveFn, wait until the Observable emits at least one item.
|
9 | * If any other value will be converted to an Observable that emits such value.
|
10 | * - The Observable item will not be unwrapped.
|
11 | * - The Observable stream itself will be provided when the resolve is injected or bound elsewhere.
|
12 | *
|
13 | * #### Example:
|
14 | *
|
15 | * The `Transition` will wait for the `main.home` resolve observables to emit their first value.
|
16 | * Promises will be unwrapped and returned as observables before being provided to components.
|
17 | * ```js
|
18 | * var mainState = {
|
19 | * name: 'main',
|
20 | * resolve: mainResolves, // defined elsewhere
|
21 | * resolvePolicy: { async: RXWAIT },
|
22 | * }
|
23 | * ```
|
24 | */
|
25 | function RXWAIT(resolveFnValue) {
|
26 | if (!(resolveFnValue instanceof rxjs_1.Observable)) {
|
27 | resolveFnValue = rxjs_1.of(resolveFnValue);
|
28 | }
|
29 | var data$ = resolveFnValue.pipe(operators_1.shareReplay(1));
|
30 | return data$
|
31 | .pipe(operators_1.first())
|
32 | .toPromise()
|
33 | .then(function () {
|
34 | return data$;
|
35 | });
|
36 | }
|
37 | exports.RXWAIT = RXWAIT;
|
38 | //# sourceMappingURL=rx-async-policy.js.map |
\ | No newline at end of file |