lastEventID
只读特性在
ExtendableMessageEvent
interface represents, in
服务器发送事件
, the last event ID of the event source. This is an empty string.
var myLastEventId = extendableMessageEvent.lastEventId;
A
DOMString
.
When the following code is used inside a service worker to respond to a push messages by sending the data received via
PushMessageData
to the main context via a
channel message
, the event object of
onmessage
将是
ExtendableMessageEvent
.
var port;
self.addEventListener('push', function(e) {
var obj = e.data.json();
if(obj.action === 'subscribe' || obj.action === 'unsubscribe') {
port.postMessage(obj);
} else if(obj.action === 'init' || obj.action === 'chatMsg') {
port.postMessage(obj);
}
});
self.onmessage = function(e) {
console.log(e.lastEventId);
port = e.ports[0];
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
服务工作者
The definition of 'ExtendableMessageEvent.lastEventId' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
lastEventId
|
Chrome ? | Edge 17 |
Firefox
45
注意事项
|
IE 不支持 No | Opera ? | Safari 不支持 No | WebView Android 不支持 No | Chrome Android ? | Firefox Android 45 | Opera Android ? | Safari iOS 不支持 No | Samsung Internet Android ? |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
见实现注意事项。
ExtendableMessageEvent
缓存
CacheStorage
Client
Clients
ExtendableEvent
FetchEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient