Service Workers APIservice
The ExtendableMessageEvent() constructor creates a new ExtendableMessageEvent object.
Syntax
new ExtendableMessageEvent(type)
new ExtendableMessageEvent(type, options)
Parameters
type- : A string with the name of the event.
It is case-sensitive and browsers set it to
messageerrorormessage.
- : A string with the name of the event.
It is case-sensitive and browsers set it to
options- : An object that, in addition of the properties defined in ExtendableEvent/ExtendableEvent, can have the following properties:
data- : The event's data; this can be any data type. It defaults to
null.
- : The event's data; this can be any data type. It defaults to
origin- : A string that defines the origin of the corresponding service worker's environment settings object.
It defaults to
"".
- : A string that defines the origin of the corresponding service worker's environment settings object.
It defaults to
lastEventId- : A string that defines the last event ID of the event source. It defaults to
"".
- : A string that defines the last event ID of the event source. It defaults to
source- : The Client, ServiceWorker or MessagePort that sent the message.
It defaults to
null.
- : The Client, ServiceWorker or MessagePort that sent the message.
It defaults to
ports- : An array containing the MessagePort objects connected to the channel sending the message. It defaults to an empty array.
- : An object that, in addition of the properties defined in ExtendableEvent/ExtendableEvent, can have the following properties:
Return value
A new ExtendableMessageEvent object.
Examples
const options = {
data: "hello message",
source: MessagePortReference,
ports: MessagePortListReference,
};
const myEME = new ExtendableMessageEvent("message", init);
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
