workbox-bgsync

0.3.0 • Public • Published

Workbok-bgSync

npm npm

Adds a react component to list the offline requests made by workbox's backgroundSync.

Getting Started

The package comes with a script to be added in your service worker and a react component.

Prerequisites

A service worker with workbox registed and active.

eg:

importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.2.0/workbox-sw.js');

#...
#Precache
#...

Installing

Service Worker

Add the script to your service woker after workbox

importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.2.0/workbox-sw.js');
importScripts('https://rawgit.com/abhiagri/workbox-bgsync/master/dist/sw.js');

...

You can also download the file and import it locally

Register Routes
const bgSync = bgSyncPlugin('queueName');
workbox.routing.registerRoute(
  /\/api\/.*/,
  workbox.strategies.networkOnly({
    plugins: [bgSync],
  }),
  'POST',
);

React Component

npm install workbox-bgsync
import Requests from 'workbox-bgsync'

...

render() {
    return <Requests />
}

Authors

  • Abhishek Lal - Initial work - GitHub

License

This project is licensed under the MIT License

Package Sidebar

Install

npm i workbox-bgsync

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

24.7 kB

Total Files

11

Last publish

Collaborators

  • abhisheklalnediya