What Web Can Do Today?

Can I rely on the Web Platform features to build my app?

An overview of the device integration HTML5 APIs

Background Sync

The Background Sync API allows authorized Web applications to not rely on having stable internet connection and defer network-related operations to the moment the connection is available. The API is bound to the Service Worker, which is the code execution model that is separated from the owning Web application. This allows the Background Sync to operate also after the application window was closed.

The API itself is only a way of signaling the application about the restored connectivity. It might be used together with any Offline Storage solution to implement a data synchronization scheme or a replay mechanism for the network requests issued when the application was offline

As of early 2020, the API is only implemented in Chromium-based browsers.

The specification is complemented with Periodic Background Sync that allows requesting periodic events waking up the Service Worker, useful for automatic data synchronization scenarios.

API glimpse

serviceWorkerRegistration.sync.register('syncTag')
Requests an one-off sync registration. Returns a Promise when the request has been registered.
self.addEventListener('sync', listener)
An event fired within the Service Worker instance when there is a connection available and the synchronization is possible. The listener is expected to call event.waitUntil(promise) specifying a Promise that resolves when the sync handling has been completed.

Resources

Get in touch