ExtendableEvent.waitUntil()
作業が進行中であることをイベントディスパッチャーに通知します。 また、その作業が成功したかどうかを検出するためにも使用できます。
callback内で即座に呼び出される
イベント処理中に非同期タスクが完了するまで処理をブロックする
code:js
addEventListener('install', (event) => {
const preCache = async () => {
const cache = await caches.open('static-v1');
return cache.addAll([
'/',
'/about/',
'/static/styles.css'
]);
};
event.waitUntil(preCache());
});