Class ExtendableEvent
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The ExtendableEvent interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.
[Value("ExtendableEvent")]
public class ExtendableEvent : Event
- Inheritance
-
ExtendableEvent
- Derived
- Inherited Members
Remarks
If WaitUntil(Task<dynamic>) is called outside of the ExtendableEvent handler, the browser should throw an InvalidStateError; note also that multiple calls will stack up, and the resulting promises will be added to the list of extend lifetime promises.
This interface inherits from the Event interface.
NOTE
This interface is only available when the global scope is a ServiceWorkerGlobalScope. It is not available when it is a Window, or the scope of another kind of worker.
-Using Service Workers
-Service workers basic code example
-Using web workers
Constructors
ExtendableEvent()
public ExtendableEvent()
ExtendableEvent(string, ExtendableEventInit)
The ExtendableEvent() constructor creates a new ExtendableEvent object.
public ExtendableEvent(string type, ExtendableEventInit eventInitDict = null)
Parameters
typestringeventInitDictExtendableEventInit
Remarks
Methods
WaitUntil(Task<dynamic>)
The ExtendableEvent.waitUntil()
method tells the event dispatcher that work is ongoing. It can also be used to detect
whether that work was successful. In service workers, waitUntil() tells
the browser that work is ongoing until the promise settles, and it shouldn't terminate
the service worker if it wants that work to complete.
[Value("waitUntil")]
public GlobalObject.Undefined WaitUntil(Task<dynamic> f)
Parameters
fTask<dynamic>
Returns
Remarks
The ServiceWorkerGlobalScopeinstall events in service workers usewaitUntil() to hold the service worker in
the Installing phase until tasks
complete. If the promise passed to waitUntil() rejects, the install is
considered a failure, and the installing service worker is discarded. This is primarily
used to ensure that a service worker is not considered installed until all of the core
caches it depends on are successfully populated.
The ServiceWorkerGlobalScopeactivate events in service workers usewaitUntil() to buffer functional events such as fetch andpush until the promise passed to waitUntil() settles. This
gives the service worker time to update database schemas and delete outdated
Cache, so other events can rely on a completely upgraded state.
The waitUntil() method must be initially called within the event callback,
but after that it can be called multiple times, until all the promises passed to it
settle.