From the course: JavaScript: Service Workers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Make your service worker useful quickly - JavaScript Tutorial
From the course: JavaScript: Service Workers
Make your service worker useful quickly
- [Instructor] Let's analyze this situation. So, we have a service worker, it's currently activated and running, and it has some clients, controlled clients. So, pages, PWAs, iFrames, or workers. But then a new service worker appears. So, we know when that happens, the new service worker is being installed and that service worker is waiting. The old service worker is still up and running and it's still the one that is handling the clients, so, it's still the controller. Well, sometimes, it might be a good idea to swap the service worker as soon as possible. So, to make the new service worker available now, I don't want to wait, I want to do it now. To do that, the new service worker can skip the waiting just calling skipwaiting, so that's a function that will make that service worker now the active one. We typically do this during the install process, so after it was installed, in that case that event handler we are going to execute keepwaiting. When that happens, now the new service…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.