File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { log } from './utils.js'
22
3- export function installSW ( swLocation ) {
3+ export async function installSW ( swLocation ) {
44 if ( navigator && window && 'serviceWorker' in navigator ) {
5- window . addEventListener ( 'load' , function ( ) {
6- navigator . serviceWorker . register ( `${ swLocation } pokeapi-js-wrapper-sw.js` , { scope : './' } )
7- . catch ( error => {
8- log ( 'SW installation failed with the following error:' )
9- log ( error )
10- } )
11- } )
5+ try {
6+ const r = await navigator . serviceWorker . register ( `${ swLocation } pokeapi-js-wrapper-sw.js` , { scope : './' } )
7+ } catch ( error ) {
8+ log ( 'SW installation failed with the following error:' )
9+ log ( error )
10+ }
1211 }
1312}
Original file line number Diff line number Diff line change 44 < title > SW test</ title >
55 < script type ="module ">
66 import { Pokedex } from '../src/index.js'
7- const P = await Pokedex . init ( { cacheImages : true , swLocation : '/pokeapi-js-wrapper/test /' } ) ;
7+ const P = await Pokedex . init ( { cacheImages : true , swLocation : '. /' } ) ;
88 </ script >
99 </ head >
1010
You can’t perform that action at this time.
0 commit comments