1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { isPromise } from '../src/util/lang';
|
9 | import { Inject, Injectable, OpaqueToken, Optional } from './di';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export var APP_INITIALIZER = new OpaqueToken('Application Initializer');
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export var ApplicationInitStatus = (function () {
|
21 | |
22 |
|
23 |
|
24 | function ApplicationInitStatus(appInits) {
|
25 | var _this = this;
|
26 | this._done = false;
|
27 | var asyncInitPromises = [];
|
28 | if (appInits) {
|
29 | for (var i = 0; i < appInits.length; i++) {
|
30 | var initResult = appInits[i]();
|
31 | if (isPromise(initResult)) {
|
32 | asyncInitPromises.push(initResult);
|
33 | }
|
34 | }
|
35 | }
|
36 | this._donePromise = Promise.all(asyncInitPromises).then(function () { _this._done = true; });
|
37 | if (asyncInitPromises.length === 0) {
|
38 | this._done = true;
|
39 | }
|
40 | }
|
41 | Object.defineProperty(ApplicationInitStatus.prototype, "done", {
|
42 | |
43 |
|
44 |
|
45 | get: function () { return this._done; },
|
46 | enumerable: true,
|
47 | configurable: true
|
48 | });
|
49 | Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
|
50 | |
51 |
|
52 |
|
53 | get: function () { return this._donePromise; },
|
54 | enumerable: true,
|
55 | configurable: true
|
56 | });
|
57 | ApplicationInitStatus.decorators = [
|
58 | { type: Injectable },
|
59 | ];
|
60 |
|
61 | ApplicationInitStatus.ctorParameters = function () { return [
|
62 | { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
|
63 | ]; };
|
64 | return ApplicationInitStatus;
|
65 | }());
|
66 | function ApplicationInitStatus_tsickle_Closure_declarations() {
|
67 |
|
68 | ApplicationInitStatus.decorators;
|
69 | |
70 |
|
71 |
|
72 |
|
73 | ApplicationInitStatus.ctorParameters;
|
74 |
|
75 | ApplicationInitStatus.prototype._donePromise;
|
76 |
|
77 | ApplicationInitStatus.prototype._done;
|
78 | }
|
79 |
|
\ | No newline at end of file |