Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 ?**

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
155 views
Welcome To Ask or Share your Answers For Others

1 Answer

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) 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...