Skip to content

behzad-dev7/subscription-service

Repository files navigation

Service Worker Example

Service Workers (SWs) are a poweful tool to handle network requests separate from a web page, as scripts running in the background. They are well known to handle push notifications and background syncronization.

With service-worker builder, we can allow an app to expose its own implementation of a Service Worker, enabling VTEX stores to use such Service Worker into their scope.

Service Workers allow us to introduce 6 different event handlers, which can be implemented inside the service-workers/ folder:

  1. activateactivate.js
  2. fetchfetch.js
  3. installinstall.js
  4. messagemessage.js
  5. pushpush.js
  6. syncsync.js

Whatever is outside those 6 files, should be implemented in header.js. The implementation result in the VTEX store DevTools should be as follows:

image

Each function can be tested according to the behavior of each event handler. When triggering such event handler, the function body will be executed as follows:

image

An example is provided in this app for exploration purposes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •