Reacting to Incoming Events in a Service Worker
Learn how to install and activate a service worker.
We'll cover the following...
As service workers run in the background, their purpose is to handle events. Therefore, we attach event listeners to the service worker to react to these events.
The self
keyword is used to refer to the service worker. To add an event listener, we use the addEventListener()
method on this self
object.
Note: Service workers don’t have DOM access, so we can’t listen to DOM events like
click
.
Listening to the install
event
Access this course and 1400+ top-rated courses and projects.