Directory

← Back

serviceworker-helpers

Display a toast on available service worker update

Author

Contributors

Rating

[ This description is mirrored from README.md at github.com/morbidick/serviceworker-helpers on 2019-05-22 ]

Polymer 2 components to work with Service Workers

Published on webcomponents.org Build Status

HowTo

Register service worker

Since its more or less a one-liner to register your service worker and included in most boilerplates there is no specific element.

<script>
  if ('serviceWorker' in navigator) {
    window.addEventListener('load', function() {
      navigator.serviceWorker.register('/service-worker.js');
    });
  }
</script>

<sw-update-toast>

Displays a toast requesting the user to reload the page when a source code update is available.

The update message can be overwriten by setting message (optional). The display time can be changed by setting duration, defaults to 0 / persistend.

<link rel="import" href="serviceworker-helpers/sw-update-toast.html">

<sw-update-toast
  message="My message"
  duration="5"
></sw-update-toast>

Change the link color by setting the css var --primary-color.

Development

# Get dependencies
$ npm install

# Demo site
$ npm start

# Run tests
$ npm test

Links

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Dependencies

  • polymer#Polymer/polymer#^2.0.0
  • paper-toast#PolymerElements/paper-toast#^2.0.0
Released
2017-10-20
Maturity
IMPORTED
License
MIT License

Compatibility

Framework
Polymer 2.0+
Browser
Browser Independent
Online