Promise.all () works for IE 11

Background: I was tasked with resolving the issue with the following error:

'Promise' is undefined' 

What is part of our sessionmodel.js script:

 return Promise.all(promises); 

promises is an array of actions that should happen, and if any failure is rejected.

Question: Based on my research, IE does not support Promise , so is there any work that can be applied to this return value that will do the same thing?

+5
source share
3 answers

Since you are using Backbone, promises are probably jQuery promises. You can use the jQuery .when function to do the same as Promise.all :

 return $.when.apply($, promises); 

For most other simple situations, when you call functions like save and fetch , you can completely avoid promises by using the provided callbacks:

 model.save({ context: this, success: this.onModelSuccess }); 

There is no need to use another library because Backbone already uses jQuery (by default) if you don't like jQuery deferred or that you use something else instead of jQuery.

+4
source

The ES6 Promise specification is implemented by "good" libraries such as Q , When , RSVP , Bluebird , Lie and much more ...

If you want to know more about Promises check out this link: Promises

+1
source

I recommend you use polyfill .

+1
source

Source: https://habr.com/ru/post/1261224/


All Articles