Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/realityforge/gwt-serviceworker-linker
https://github.com/realityforge/gwt-serviceworker-linker
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/realityforge/gwt-serviceworker-linker
- Owner: realityforge
- License: apache-2.0
- Created: 2020-03-10T00:35:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-26T02:53:55.000Z (5 months ago)
- Last Synced: 2024-10-04T17:10:26.730Z (2 months ago)
- Language: Java
- Homepage:
- Size: 171 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- gwt-boot-awesome-lili - gwt-serviceworker-linker - A GWT linker that (Web Worker)
- gwt-boot-awesome-lili - gwt-serviceworker-linker - A GWT linker that (Web Worker)
README
# gwt-serviceworker-linker
[![Build Status](https://api.travis-ci.com/realityforge/gwt-serviceworker-linker.svg?branch=master)](http://travis-ci.com/realityforge/gwt-serviceworker-linker)
[](https://search.maven.org/search?q=g:org.realityforge.gwt.serviceworker)The [ServiceWorkers](https://www.w3.org/TR/service-workers/) specification enables applications
to take advantage of persistent background processing, including hooks to enable bootstrapping
of web applications while offline. This project attempts to basic AppCache behaviour using
ServiceWorkers.## Quick Start
The simplest way to serviceworker enable a GWT application is to;
* add the following dependencies into the build system. i.e.
```xml
org.realityforge.gwt.serviceworker
gwt-serviceworker-linker
0.02
provided```
* add the following snippet into the .gwt.xml file.
```xml
...
```
* launch the service worker from within the application using [Elemental2](https://github.com/google/elemental2).
```java
import static elemental2.dom.DomGlobal.*;...
if ( null != navigator.serviceWorker )
{
navigator.serviceWorker
.register( GWT.getModuleName() + "-sw.js" )
.then( registration -> {
console.log( "ServiceWorker registration successful with scope: " + registration.getScope() );// Every minute attempt to update the serviceWorker. If it does update
// then the "controllerchange" event will fire.
DomGlobal.setInterval( v -> registration.update(), 60000 );return null;
}, error -> {
console.log( "ServiceWorker registration failed: ", error );
return null;
} );navigator.serviceWorker.addEventListener( "controllerchange", e -> {
// This fires when the service worker controlling this page
// changes, eg a new worker has skipped waiting and become
// the new active worker.
console.log( "ServiceWorker updated ", e );
} );
}
...
```This should be sufficient to get your application using a serviceworker to cache static assets.