FetchEvent: handled プロパティ
メモ: この機能はサービスワーカー内でのみ利用可能です。
handled
は FetchEvent
インターフェイスのプロパティで、このイベントがフェッチアルゴリズムによって処理されたかどうかを示すプロミスを返します。このプロパティは、ブラウザーがレスポンスを消費した後にコードを実行することができ、通常は waitUntil()
メソッドと共に使用します。
値
イベントが処理されるまでは待機し、イベントが処理されると履行される Promise
です。
例
js
addEventListener("fetch", (event) => {
event.respondWith(
(async function () {
const response = await doCalculateAResponse(event.request);
event.waitUntil(
(async function () {
await doSomeAsyncStuff(); // オプション
// イベントがブラウザーによって消費されるのを待つ
await event.handled;
return doFinalStuff(); // イベントが消費された後に後始末
})(),
);
return response;
})(),
);
});
仕様書
Specification |
---|
Service Workers # dom-fetchevent-handled |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
handled |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.