Skip to content

Commit

Permalink
feat(event-target): add installing ts docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Doctor-wu committed Dec 31, 2023
1 parent d061c4e commit 9ddfbbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Workbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const SKIP_WAITING_MESSAGE = { type: 'SKIP_WAITING' }
* reacting to service worker lifecycle events.
*
* @fires WorkboxEventMap#message
* @fires WorkboxLifecycleEventMap#installing
* @fires WorkboxLifecycleEventMap#installed
* @fires WorkboxLifecycleEventMap#waiting
* @fires WorkboxLifecycleEventMap#controlling
* @fires WorkboxLifecycleEventMap#activated
* @fires WorkboxLifecycleEventMap#redundant
* @fires WorkboxLifecycleEventMap#updatefound
*/
class Workbox extends WorkboxEventTarget {
private readonly _scriptURL: string | TrustedScriptURL
Expand Down
14 changes: 13 additions & 1 deletion src/utils/WorkboxEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ export interface WorkboxLifecycleWaitingEvent extends WorkboxLifecycleEvent {
}

export interface WorkboxLifecycleEventMap {

/**
* The `installing` event is dispatched if the service-worker
* find the new version and start installing.
*
* @event workbox-window.Workbox#installing
* @type {WorkboxEvent}
* @property {ServiceWorker} sw The installing service worker instance.
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
* event.
* @property {string} type `installing`.
* @property {Workbox} target The `Workbox` instance.
*/
installing: WorkboxLifecycleEvent
/**
* The `installed` event is dispatched if the state of a
Expand Down Expand Up @@ -156,7 +169,6 @@ export interface WorkboxLifecycleEventMap {
* @property {Workbox} target The `Workbox` instance.
*/
redundant: WorkboxLifecycleEvent
updatefound: WorkboxLifecycleEvent
}

export interface WorkboxEventMap extends WorkboxLifecycleEventMap {
Expand Down

0 comments on commit 9ddfbbe

Please sign in to comment.