Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to implement promises in ie9+

I m trying to implement native promise on IE9+ and it seems that internet explorer does not Recognize the "Promise" class/object. I searched in http://caniuse.com/#search=Promise and saw that IE don't have Promise object. But this is strange because jQuery and Angular works with promises and working in IE9+. Maybe they are implementing their own Promise?? ** Can i implement my own promise ?**

like image 749
user1019872 Avatar asked Jan 08 '15 08:01

user1019872


People also ask

Can I use Promises in IE11?

IE11 neither supports arrow functions nor native Promises. Use a JS transpiler (like babel) or don't use ES6 features. For Promise support you can use a library like bluebird.

Do Promises work in IE?

'Promise' is undefined in Internet Explorer (IE 11)

What is polyfill promise?

Promise Usage. The promise is a constructor which accepts an executor function as a parameter. The executor function has a resolve callback, and a reject callback as its parameter. Once the Promise constructor is called, an async operation is initiated, say, an HTTP API call.


1 Answers

What's "native"

Being native means that it is written inside the browser's code base and not in user-level code. In order to implement promises natively in IE9 you'd have to obtain a copy of the IE9 source code from Microsoft, code those in, compile and distribute it. While that's doable that's not a very viable option.

Using promises today

On the other hand - there are several promise libraries that exist in userlevel. It's perfectly possible to implement your own promise implementation - here is a great blog post on how.

You can freely include a library like bluebird (bluebird) or Q that fulfill this API and will continue working well with ES6 promises in the future. It is worth mentioning that Bluebird for instance runs on IE6+ so there should be no issues in your case.

For example here is Angular's implementation and here is jQuery's implementation - Angular's is more readable in my opinion.

The standard

Also note that contrary to the coment left above promises are standardized by the Promises/A+ specification with libraries like Angular conform to and libraries like jQuery are working on conforming to and likely will in the next version. Native promises also conform to the standard and superset it.

like image 59
Benjamin Gruenbaum Avatar answered Sep 26 '22 20:09

Benjamin Gruenbaum