Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. const bgSyncPlugin = new workbox.backgroundSync.Plugin('myQueue', {
  2. callbacks: {
  3. requestWillEnqueue: (storableRequest) => {}, // I show a push notification indicating user is offline
  4. requestWillReplay: (storableRequest) => {},
  5. queueDidReplay: (storableRequestArray) => {} // If I get a response, I show a push notification
  6. }
  7. },
  8. );
  9.  
  10. workbox.routing.registerRoute(
  11. "https://myapi.com/action",
  12. workbox.strategies.networkOnly({
  13. plugins: [bgSyncPlugin]
  14. }),
  15. 'POST'
  16. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement