Limited availability
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is only available in Service Workers.
The sync
event of the ServiceWorkerGlobalScope
interface is fired when the page (or worker) that registered the event with the SyncManager
is running and as soon as network connectivity is available.
This event is not cancelable and does not bubble.
SyntaxUse the event name in methods like addEventListener()
, or set an event handler property.
addEventListener("sync", (event) => { })
onsync = (event) => { }
Event type Event properties
Inherits properties from its ancestor, ExtendableEvent
and Event
.
SyncEvent.tag
Read only
Returns the developer-defined identifier for this SyncEvent
.
SyncEvent.lastChance
Read only
Returns true
if the user agent will not make further synchronization attempts after the current attempt.
The following example shows how to respond to a sync event in the service worker.
self.addEventListener("sync", (event) => {
if (event.tag === "sync-messages") {
event.waitUntil(sendOutboxMessages());
}
});
You can also set up the event handler using the onsync
property:
self.onsync = (event) => {
// â¦
};
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4