Service Workers APIservice
The FetchEvent() constructor creates a new FetchEvent object.
Syntax
new FetchEvent(type, options)
Parameters
type- : A string with the name of the event.
It is case-sensitive and browsers always set it to
fetch.
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
options- : An object that, in addition of the properties defined in ExtendableEvent/ExtendableEvent, can have the following properties:
request- : The Request object that would have triggered the event handler.
preloadResponse- : A Promise which returns a previously-loaded response to the client.
clientId- : The Client that the current service worker is controlling. It defaults to
"".
- : The Client that the current service worker is controlling. It defaults to
isReload- : A boolean value that signifies whether the page was reloaded or not when
the event was dispatched.
trueif yes, andfalseif not. Typically, pressing the refresh button in a browser is a reload, while clicking a link and pressing the back button is not. If not present, it defaults tofalse.
- : A boolean value that signifies whether the page was reloaded or not when
the event was dispatched.
resultingClientId- : A string containing the new
clientIdif the client changes as a result of the page load. It defaults to""
- : A string containing the new
handled- : A pending promise that will be fulfilled once the event has been handled.
- : An object that, in addition of the properties defined in ExtendableEvent/ExtendableEvent, can have the following properties:
Return value
A new FetchEvent object.
Specifications
Browser compatibility
See also
- Promise
- Fetch API
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
