Skip to content

Instantly share code, notes, and snippets.

import { html } from 'lit';
import { makeObservable, observable, action } from "mobx"
import { MobxLitElement } from '@adobe/lit-mobx';
// create a mobx observable
class Counter {
count = 0;
increment() {
this.count++;
@beebole
beebole / index(html)2.js
Last active July 25, 2017 20:35
Mobile offline - AppCache setup
//Check if a new cache is available on page load.
window.addEventListener('load', function( ) {
window.applicationCache.addEventListener('updateready', function( ) {
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
window.applicationCache.swapCache();
window.location.reload( true );
} else {
// Manifest didn't changed. Nothing new to server.
}
}, false);
@beebole
beebole / load-appcache.html
Created July 25, 2017 20:29
Mobile offline - AppCache setup
<!DOCTYPE html>
<html manifest="offline.appcache">
<head>
<title>loading appCache</title>
</head>
<body></body>
</html>
@beebole
beebole / index(html)1.js
Last active July 25, 2017 20:35
Mobile offline - AppCache setup
} else if ('applicationCache' in window) {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = 'load-appcache.html';
document.body.appendChild(iframe);
@beebole
beebole / index.html
Last active July 25, 2017 20:33
Mobile offline - AppCache setup
<html manifest="offline.appcache">
@beebole
beebole / sw9.js
Created July 25, 2017 19:56
Mobile offline - SW file
.then( function( resp ){
@beebole
beebole / sw8.js
Created July 25, 2017 19:55
Mobile offline - SW file
return fetch( event.request );
@beebole
beebole / sw7.js
Created July 25, 2017 19:55
Mobile offline - SW file
caches.match( event.request )
.then(function( response ) {
if ( response ) {
return response;
}
@beebole
beebole / sw6.js
Created July 25, 2017 19:54
self.addEventListener( 'fetch', function( event ) {
event.respondWith(
@beebole
beebole / sw5.js
Created July 25, 2017 19:53
Mobile offline - SW file
self.addEventListener( 'fetch', function( event ) {