blob: 1d5dbf6423c2fd8ed54f5692ae3af8546ad3eb05 (
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
33
34
|
<script lang="ts">
import { getToastStore, Toast } 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>
|