blob: 6c778b66457f7457380a57963a6d809b4de62b70 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<script lang="ts">
import { getToastStore } from '@skeletonlabs/skeleton';
import { useRegisterSW } from 'virtual:pwa-register/svelte';
const toastStore = getToastStore();
const { updateServiceWorker } = useRegisterSW({
onRegisteredSW(r) {
console.log('SW Registered: ', r);
},
onNeedRefresh() {
toastStore.trigger({
message: 'A new version of the application is available.',
autohide: false,
action: {
label: 'Refresh',
response: updateServiceWorker
}
});
},
onOfflineReady() {
toastStore.trigger({
background: 'variant-filled-success',
message: 'Now ready for offline use!',
timeout: 5000
});
},
onRegisterError(err) {
console.error('SW Registration Error: ', err);
}
});
</script>
|