ContentIndexEvent
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Note: This feature is only available inService Workers.
TheContentIndexEvent interface of thecontent index defines the object used to represent thecontentdelete event.
This event is sent to theglobal scope of aServiceWorker. It contains the id of the indexed content to be removed.
Thecontentdelete event is only fired when the deletion happens due to interaction with the browser's built-in user interface. It is not fired when theContentIndex.delete method is called.
In this article
Constructor
ContentIndexEvent()ExperimentalCreates and returns a new
ContentIndexEventobject whose type and other options are configured as specified.
Instance properties
In addition to the properties listed below, this interface inherits the properties of its parent interface,ExtendableEvent.
idRead onlyExperimentalA
Stringwhich identifies the deleted content index via it'sid.
Instance methods
WhileContentIndexEvent offers no methods of its own, it inherits any specified by its parent interface,ExtendableEvent.
Examples
This example shows theservice worker script listening for thecontentdelete event and logs the removed content index id.
self.addEventListener("contentdelete", (event) => { console.log(event.id); // logs content index id, which can then be used to determine what content to delete from your cache});Specifications
| Specification |
|---|
| Content Index> # content-index-event> |