docs(service-worker): add `UpdateActivated`/`AvailableEvent` to the public API (#23138)

PR Close #23138
This commit is contained in:
George Kalpakas 2018-04-02 14:51:06 +03:00 committed by Jason Aden
parent 9953fe7c00
commit 7aed64d3a1
3 changed files with 37 additions and 11 deletions

View File

@ -14,6 +14,7 @@
* found in the LICENSE file at https://angular.io/license
*/
export {UpdateActivatedEvent, UpdateAvailableEvent} from './low_level';
export {ServiceWorkerModule} from './module';
export {SwPush} from './push';
export {SwUpdate} from './update';
export {SwUpdate} from './update';

View File

@ -11,27 +11,26 @@ import {filter, map, publish, switchMap, take, tap} from 'rxjs/operators';
export const ERR_SW_NOT_SUPPORTED = 'Service workers are disabled or not supported by this browser';
export interface Version {
hash: string;
appData?: Object;
}
/**
* An event emitted when a new version of the app is available.
*
* @experimental
*/
export interface UpdateAvailableEvent {
type: 'UPDATE_AVAILABLE';
current: Version;
available: Version;
current: {hash: string, appData?: Object};
available: {hash: string, appData?: Object};
}
/**
* An event emitted when a new version of the app has been downloaded and activated.
*
* @experimental
*/
export interface UpdateActivatedEvent {
type: 'UPDATE_ACTIVATED';
previous?: Version;
current: Version;
previous?: {hash: string, appData?: Object};
current: {hash: string, appData?: Object};
}
export type IncomingEvent = UpdateAvailableEvent | UpdateActivatedEvent;
@ -52,7 +51,7 @@ function errorObservable(message: string): Observable<any> {
/**
* @experimental
*/
*/
export class NgswCommChannel {
/**
* @internal

View File

@ -27,3 +27,29 @@ export declare class SwUpdate {
activateUpdate(): Promise<void>;
checkForUpdate(): Promise<void>;
}
/** @experimental */
export interface UpdateActivatedEvent {
current: {
hash: string;
appData?: Object;
};
previous?: {
hash: string;
appData?: Object;
};
type: 'UPDATE_ACTIVATED';
}
/** @experimental */
export interface UpdateAvailableEvent {
available: {
hash: string;
appData?: Object;
};
current: {
hash: string;
appData?: Object;
};
type: 'UPDATE_AVAILABLE';
}