Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Adding plugin usage to module guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Gaunt committed Jan 29, 2018
1 parent 687d52d commit 112812d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/content/en/tools/workbox/modules/workbox-background-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ book_path: /web/tools/workbox/_book.yaml
description: The module guide for workbox-background-sync.

{# wf_blink_components: N/A #}
{# wf_updated_on: 2017-12-01 #}
{# wf_updated_on: 2018-01-29 #}
{# wf_published_on: 2017-11-27 #}

# Workbox Background Sync {: .page-title }
Expand Down Expand Up @@ -32,6 +32,26 @@ BackgroundSync.

## Basic Usage

The easiest way to use Background Sync is to use the `Plugin` that will
automatically Queue up failed requests and retry them for future `sync`
events.

```javascript
const bgSyncPlugin = new workbox.backgroundSync.Plugin('myQueueName', {
maxRetentionTime: 24 * 60 * 60 * 1000 // Retry for max of 24 Hours
});

workbox.routing.registerRoute(
/\/api\/.*\/*.json/,
workbox.strategies.networkOnly({
plugins: [bgSyncPlugin]
}),
'POST'
);
```

## Advanced Usage

Workbox Background Sync gives you a `Queue` class, which you can
instantiate and then add failed requests to. The failed requests are stored
in
Expand Down

0 comments on commit 112812d

Please sign in to comment.