docs(service-worker): improve API docs for SwPush/SwUpdate (#23138)

PR Close #23138
This commit is contained in:
George Kalpakas
2018-05-17 15:30:36 +03:00
committed by Jason Aden
parent 77942cc690
commit bfeed842ee
3 changed files with 33 additions and 46 deletions

View File

@ -21,9 +21,22 @@ import {ERR_SW_NOT_SUPPORTED, NgswCommChannel, UpdateActivatedEvent, UpdateAvail
*/
@Injectable()
export class SwUpdate {
/**
* Emits an `UpdateAvailableEvent` event whenever a new app version is available.
*/
readonly available: Observable<UpdateAvailableEvent>;
/**
* Emits an `UpdateActivatedEvent` event whenever the app has been updated to a new version.
*/
readonly activated: Observable<UpdateActivatedEvent>;
/**
* True if the Service Worker is enabled (supported by the browser and enabled via
* `ServiceWorkerModule`).
*/
get isEnabled(): boolean { return this.sw.isEnabled; }
constructor(private sw: NgswCommChannel) {
if (!sw.isEnabled) {
this.available = NEVER;
@ -34,12 +47,6 @@ export class SwUpdate {
this.activated = this.sw.eventsOfType<UpdateActivatedEvent>('UPDATE_ACTIVATED');
}
/**
* Returns true if the Service Worker is enabled (supported by the browser and enabled via
* ServiceWorkerModule).
*/
get isEnabled(): boolean { return this.sw.isEnabled; }
checkForUpdate(): Promise<void> {
if (!this.sw.isEnabled) {
return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));