fix(router): do not finish bootstrap until all the routes are resolved (#14608)
Fixes #12162 closes #14155
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {PlatformLocation} from '@angular/common';
|
||||
import {LOCATION_INITIALIZED, PlatformLocation} from '@angular/common';
|
||||
import {APP_INITIALIZER, InjectionToken, NgZone} from '@angular/core';
|
||||
|
||||
import {WebWorkerPlatformLocation} from './platform_location';
|
||||
@ -25,9 +25,18 @@ export const WORKER_APP_LOCATION_PROVIDERS = [
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone],
|
||||
},
|
||||
{
|
||||
provide: LOCATION_INITIALIZED,
|
||||
useFactory: locationInitialized,
|
||||
deps: [PlatformLocation],
|
||||
},
|
||||
];
|
||||
|
||||
function appInitFnFactory(platformLocation: WebWorkerPlatformLocation, zone: NgZone): () =>
|
||||
export function locationInitialized(platformLocation: WebWorkerPlatformLocation) {
|
||||
return platformLocation.initialized;
|
||||
}
|
||||
|
||||
export function appInitFnFactory(platformLocation: WebWorkerPlatformLocation, zone: NgZone): () =>
|
||||
Promise<boolean> {
|
||||
return () => zone.runGuarded(() => platformLocation.init());
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
||||
private _hashChangeListeners: Array<Function> = [];
|
||||
private _location: LocationType = null;
|
||||
private _channelSource: EventEmitter<Object>;
|
||||
public initialized: Promise<any>;
|
||||
private initializedResolve: () => void;
|
||||
|
||||
constructor(
|
||||
brokerFactory: ClientMessageBrokerFactory, bus: MessageBus, private _serializer: Serializer) {
|
||||
@ -48,6 +50,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
||||
}
|
||||
}
|
||||
});
|
||||
this.initialized = new Promise(res => this.initializedResolve = res);
|
||||
}
|
||||
|
||||
/** @internal **/
|
||||
@ -58,6 +61,7 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
||||
.then(
|
||||
(val: LocationType) => {
|
||||
this._location = val;
|
||||
this.initializedResolve();
|
||||
return true;
|
||||
},
|
||||
err => { throw new Error(err); });
|
||||
|
Reference in New Issue
Block a user