-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update events on BackgroundFetchRegistration (#12851)
- Loading branch information
Showing
15 changed files
with
99 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
files/en-us/web/api/backgroundfetchregistration/onprogress/index.md
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
files/en-us/web/api/backgroundfetchregistration/progress_event/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: 'BackgroundFetchRegistration: progress event' | ||
slug: Web/API/BackgroundFetchRegistration/progress_event | ||
tags: | ||
- progress | ||
- API | ||
- Reference | ||
- Event | ||
browser-compat: api.BackgroundFetchRegistration.progress_event | ||
--- | ||
{{APIRef("Background Fetch API")}} | ||
|
||
The **`progress`** event of the {{domxref("BackgroundFetchRegistration")}} interface thrown when the associated background fetch progresses. | ||
|
||
Practically, this event is fired when any of the following properties will return a new value: | ||
|
||
- {{domxref("BackgroundFetchRegistration.uploaded", "uploaded")}}, | ||
- {{domxref("BackgroundFetchRegistration.downloaded", "downloaded")}}, | ||
- {{domxref("BackgroundFetchRegistration.result", "result")}}, or | ||
- {{domxref("BackgroundFetchRegistration.failureReason", "failureReason")}}. | ||
|
||
## Syntax | ||
|
||
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set the `onprogress` event property on the relevent {{domxref("BackgroundFetchRegistration")}} object. | ||
|
||
```js | ||
addEventListener('progress', event => { }) | ||
onprogress = event => { } | ||
``` | ||
|
||
## Event type | ||
|
||
A generic {{domxref("Event")}} with no added properties. | ||
|
||
## Example | ||
|
||
The following example demonstrates how to log the progress of a download. The code first checks that a `downloadTotal` was provided when the background fetch was registered. This is then used to calculate the percentage, based on the `downloaded` property. | ||
|
||
```js | ||
bgFetch.addEventListener('progress', () => { | ||
if (!bgFetch.downloadTotal) return; | ||
const percent = Math.round(bgFetch.downloaded / bgFetch.downloadTotal * 100); | ||
console.log(`Download progress: ${percent}%`); | ||
}); | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters