angular-cn/packages/service-worker
Sonu Kapoor 00efacf561 feat(service-worker): support timeout in `registerWhenStable` SW registration strategy (#35870)
Previously, when using the `registerWhenStable` ServiceWorker
registration strategy (which is also the default) Angular would wait
indefinitely for the [app to stabilize][1], before registering the
ServiceWorker script. This could lead to a situation where the
ServiceWorker would never be registered when there was a long-running
task (such as an interval or recurring timeout).

Such tasks can often be started by a 3rd-party dependency (beyond the
developer's control or even without them realizing). In addition, this
situation is particularly hard to detect, because the ServiceWorker is
typically not used during development and on production builds a
previous ServiceWorker instance might be already active.

This commit enhances the `registerWhenStable` registration strategy by
adding support for an optional `<timeout>` argument, which guarantees
that the ServiceWorker will be registered when the timeout expires, even
if the app has not stabilized yet.

For example, with `registerWhenStable:5000` the ServiceWorker will be
registered as soon as the app stabilizes or after 5 seconds if the app
has not stabilized by then.

Related to #34464.

[1]: https://angular.io/api/core/ApplicationRef#is-stable-examples

PR Close #35870
2020-03-27 10:47:44 -07:00
..
cli perf: don't create holey arrays (#32155) 2019-08-21 08:27:43 -07:00
config test: setup circular dependency tests for all entry points (#34774) 2020-01-23 11:36:40 -08:00
src feat(service-worker): support timeout in `registerWhenStable` SW registration strategy (#35870) 2020-03-27 10:47:44 -07:00
test feat(service-worker): support timeout in `registerWhenStable` SW registration strategy (#35870) 2020-03-27 10:47:44 -07:00
testing build: TypeScript 3.5 upgrade (#31615) 2019-07-25 17:05:23 -07:00
worker build: no longer run tslint from within gulp task (#35800) 2020-03-03 09:20:49 -08:00
BUILD.bazel build: provide full paths to `ts_api_guardian_test_npm_package` and `ts_api_guardian_test` (#36034) 2020-03-12 09:49:00 -07:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
index.ts fix(aio): add service worker entrypoint to aio build (#19875) 2017-10-23 19:31:42 -04:00
package.json build(packaging): add repository.directory field to package.jsons (#27544) 2020-02-25 13:12:45 -08:00
public_api.ts feat(service-worker): introduce the @angular/service-worker package (#19274) 2017-09-28 16:18:12 -07:00
safety-worker.js feat(service-worker): add helper script which will uninstall SW (#21863) 2018-01-30 11:43:03 -08:00