
This commit also waits for the app to stabilize, before starting to check for ServiceWorker updates. This avoids setting up a long timeout, which would prevent the app from stabilizing and thus cause issues with Protractor. PR Close #23093
20 lines
682 B
TypeScript
20 lines
682 B
TypeScript
import { enableProdMode, ApplicationRef } from '@angular/core';
|
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
import 'rxjs/add/operator/first';
|
|
|
|
import { AppModule } from './app/app.module';
|
|
import { environment } from './environments/environment';
|
|
|
|
if (environment.production) {
|
|
enableProdMode();
|
|
}
|
|
|
|
platformBrowserDynamic().bootstrapModule(AppModule).then(ref => {
|
|
if (environment.production && 'serviceWorker' in (navigator as any)) {
|
|
const appRef: ApplicationRef = ref.injector.get(ApplicationRef);
|
|
appRef.isStable.first(v => v).subscribe(() => {
|
|
(navigator as any).serviceWorker.register('/worker-basic.min.js');
|
|
});
|
|
}
|
|
});
|