class final
Subscribe to update notifications from the Service Worker, trigger update checks, and forcibly activate updates.
class SwUpdate {
versionUpdates: Observable<VersionEvent>
available: Observable<UpdateAvailableEvent>
activated: Observable<UpdateActivatedEvent>
unrecoverable: Observable<UnrecoverableStateEvent>
isEnabled: boolean
checkForUpdate(): Promise<boolean>
activateUpdate(): Promise<boolean>
} | Property | Description |
|---|---|
versionUpdates: Observable<VersionEvent> | Read-Only Emits a Emits a Emits a |
available: Observable<UpdateAvailableEvent> | Deprecated Read-Only Emits an Deprecated Use The behavior of import { filter, map } from 'rxjs/operators';
// ...
const updatesAvailable = swUpdate.versionUpdates.pipe(
filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'),
map(evt => ({
type: 'UPDATE_AVAILABLE',
current: evt.currentVersion,
available: evt.latestVersion,
}))); |
activated: Observable<UpdateActivatedEvent> | Deprecated Read-Only Emits an Deprecated Use the return value of |
unrecoverable: Observable<UnrecoverableStateEvent> | Read-Only Emits an |
isEnabled: boolean | Read-Only True if the Service Worker is enabled (supported by the browser and enabled via |
| checkForUpdate() |
|---|
| Checks for an update and waits until the new version is downloaded from the server and ready for activation. |
|
| activateUpdate() |
|---|
| Updates the current client (i.e. browser tab) to the latest version that is ready for activation. |
|
| In most cases, you should not use this method and instead should update a client by reloading the page.
|
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/service-worker/SwUpdate