diff --git a/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts b/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts
index 194b555ace..7375ac5bae 100755
--- a/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts
+++ b/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts
@@ -1,15 +1,17 @@
-import { Injectable } from '@angular/core';
+import { ApplicationRef, Injectable } from '@angular/core';
import { SwUpdate } from '@angular/service-worker';
-
-
-// #docregion sw-check-update
-import { interval } from 'rxjs';
+import { concat, interval } from 'rxjs';
+import { first } from 'rxjs/operators';
@Injectable()
export class CheckForUpdateService {
- constructor(updates: SwUpdate) {
- interval(6 * 60 * 60).subscribe(() => updates.checkForUpdate());
+ constructor(appRef: ApplicationRef, updates: SwUpdate) {
+ // Allow the app to stabilize first, before starting polling for updates with `interval()`.
+ const appIsStable$ = appRef.isStable.pipe(first(isStable => isStable === true));
+ const everySixHours$ = interval(6 * 60 * 60 * 1000);
+ const everySixHoursOnceAppIsStable$ = concat(appIsStable$, everySixHours$);
+
+ everySixHoursOnceAppIsStable$.subscribe(() => updates.checkForUpdate());
}
}
-// #enddocregion sw-check-update
diff --git a/aio/content/guide/service-worker-communications.md b/aio/content/guide/service-worker-communications.md
index 33662527a8..18a41061d3 100644
--- a/aio/content/guide/service-worker-communications.md
+++ b/aio/content/guide/service-worker-communications.md
@@ -35,11 +35,23 @@ It's possible to ask the service worker to check if any updates have been deploy
Do this with the `checkForUpdate()` method:
-