From the course: JavaScript: Progressive Web Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Getting started with ES6 promises

Getting started with ES6 promises - JavaScript Tutorial

From the course: JavaScript: Progressive Web Applications

Start my 1-month free trial

Getting started with ES6 promises

- [Narrator] Before we jump into adding a service worker to the PWA, we need to explore JavaScript promises, as a service worker API is heavily dependent on promises. Promises have been supported by browsers for quite some time, in internet years. You can see what service worker features are implemented in browsers, including promises at JakeArchibald.github.io At their heart, promises are placeholders for something that may or may not be fulfilled. A promise is said to be fulfilled if the action related to the promise is successful. A promise is said to be rejected if that action fails. A promise is pending if its status hasn't been determined, and settled if the outcome is no. For the most part, you'll be dealing with promise objects that are returned from methods in the service worker API. If you need to create a promise object, the constructor takes a single call back method as its parameter. That call back itself has two parameters, resolve and reject. It might look something…

Contents