Skip to content

Commit

Permalink
docs(service-worker): update default value of `SwRegistrationOptions#…
Browse files Browse the repository at this point in the history
…registrationStrategy` (#37555)

The default value was changed from `registerWhenStable` to
`registerWhenStable:30000` in 29e8a64,
but the decumentation was not updated to reflect that.

This commit updates the documentation to mention the correct default
value.

PR Close #37555
  • Loading branch information
gkalpak authored and subratpalhar92 committed Aug 15, 2020
1 parent 20a0cb7 commit 192b504
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions aio/content/guide/service-worker-communications.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ This method returns a `Promise` which indicates that the update check has comple

<div class="alert is-important">

In order to avoid negatively affecting the initial rendering, `ServiceWorkerModule` will by default
wait for the app to stabilize, before registering the ServiceWorker script. Constantly polling for
updates, e.g. with `interval()`, will prevent the app from stabilizing and the ServiceWorker
script will never be registered with the browser.
In order to avoid negatively affecting the initial rendering of the page, `ServiceWorkerModule` will by default wait for up to 30 seconds for the app to stabilize, before registering the ServiceWorker script.
Constantly polling for updates, e.g. with [setInterval()](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) or RxJS' [interval()](https://rxjs.dev/api/index/function/interval), will prevent the app from stabilizing and the ServiceWorker script will not be registered with the browser until the 30 seconds upper limit is reached.

You can avoid that by waiting for the app to stabilize first, before starting to poll for updates
(as shown in the example above).
Expand Down
2 changes: 1 addition & 1 deletion packages/service-worker/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export abstract class SwRegistrationOptions {
* The function will be used at runtime to obtain and subscribe to the `Observable` and the
* ServiceWorker will be registered as soon as the first value is emitted.
*
* Default: 'registerWhenStable'
* Default: 'registerWhenStable:30000'
*/
registrationStrategy?: string|(() => Observable<unknown>);
}
Expand Down

0 comments on commit 192b504

Please sign in to comment.