Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: ExtendableEvent
Source: JSObjects/BackgroundFetchEvent.cs
MDN Reference: BackgroundFetchEvent on MDN
The BackgroundFetchEvent interface of the Background Fetch API is the event type for background fetch events dispatched on the service worker global scope. It is the event type passed to backgroundfetchclick event and backgroundfetchabort event. https://developer.mozilla.org/en-US/docs/Web/API/BackgroundFetchEvent
| Property | Type | Access | Description |
|---|---|---|---|
Registration |
BackgroundFetchRegistration |
get | Returns the BackgroundFetchRegistration that the event was initialized to. |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<BackgroundFetchEvent>(...)or constructornew BackgroundFetchEvent(...)
addEventListener("backgroundfetchclick", (event) => {
const bgFetch = event.registration;
if (bgFetch.result === "success") {
clients.openWindow("/latest-podcasts");
} else {
clients.openWindow("/download-progress");
}
});