Promise

Promise in ES6 is an instrinsic Global object. It can be called only as constructor, not as a function (if so, it will throw an exception). Promise should be a subclassable object, so we can iuse the extend clause of a class definition, however in a constructor of the new object we still need to call super.call to initialize instance and internal state of Promise.

new Promise(executor)

New instance of Promise object will contain these methods and properties:

Promise static methods

Executor function

The Promise will pass to the executor function two parameters, which are functions:

These to function should be called and when an asynchronous event was resolved, or rejected.

The widely use approach used by jQuery.defered, angular.$q.defered (which is basically based on kriskowal’s Q, search on github) is not compliant with ES6 specification. However angular uses the compliant version of promise as well (see angular doc). My proposal as a good practice is a usage the ES6 compliant within the angular code as well, and not to use jQuery.defered version.

It is possible to send by the resolve() only one argument, however, we can send an array and in a then() method We can use ([ParameterOne, ParameterTwo, ParameterThree])=>{}; notation;

Resources