Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.71 KB

File metadata and controls

39 lines (29 loc) · 1.71 KB

BackgroundFetchEvent

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

Properties

Property Type Access Description
Registration BackgroundFetchRegistration get Returns the BackgroundFetchRegistration that the event was initialized to.

Examples

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., readyState becomes ReadyState)
  • Events use ActionEvent with +=/-= (e.g., addEventListener("click", fn) becomes OnClick += handler)
  • Async methods return Task<T> instead of Promise<T>
  • Objects should be disposed with using statements
  • Access via JS.Get<BackgroundFetchEvent>(...) or constructor new BackgroundFetchEvent(...)
addEventListener("backgroundfetchclick", (event) => {
  const bgFetch = event.registration;

  if (bgFetch.result === "success") {
    clients.openWindow("/latest-podcasts");
  } else {
    clients.openWindow("/download-progress");
  }
});

See full example on MDN