UNPKG

2.48 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { isPromise } from '../src/util/lang';
9import { Inject, Injectable, OpaqueToken, Optional } from './di';
10/**
11 * A function that will be executed when an application is initialized.
12 * @experimental
13 */
14export var /** @type {?} */ APP_INITIALIZER = new OpaqueToken('Application Initializer');
15/**
16 * A class that reflects the state of running {\@link APP_INITIALIZER}s.
17 *
18 * \@experimental
19 */
20export var ApplicationInitStatus = (function () {
21 /**
22 * @param {?} appInits
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 * @return {?}
44 */
45 get: function () { return this._done; },
46 enumerable: true,
47 configurable: true
48 });
49 Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
50 /**
51 * @return {?}
52 */
53 get: function () { return this._donePromise; },
54 enumerable: true,
55 configurable: true
56 });
57 ApplicationInitStatus.decorators = [
58 { type: Injectable },
59 ];
60 /** @nocollapse */
61 ApplicationInitStatus.ctorParameters = function () { return [
62 { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
63 ]; };
64 return ApplicationInitStatus;
65}());
66function ApplicationInitStatus_tsickle_Closure_declarations() {
67 /** @type {?} */
68 ApplicationInitStatus.decorators;
69 /**
70 * @nocollapse
71 * @type {?}
72 */
73 ApplicationInitStatus.ctorParameters;
74 /** @type {?} */
75 ApplicationInitStatus.prototype._donePromise;
76 /** @type {?} */
77 ApplicationInitStatus.prototype._done;
78}
79//# sourceMappingURL=application_init.js.map
\No newline at end of file