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

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

Is any jQuery version compliant to Promise/A specifications?

After going through several articles I have come to know that promise implementation is there in jQuery. But I am not sure whether any version of jQuery is Promise/A compliant or not.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Update 2015: jQuery 3.0 is Promises/A+ compatible. See this issue on GitHub so 3.0 beta is 3.0 compatible and when 3.0 is out it will also be compatible. Until then - the below still applies.

All jQuery versions (up to 3.0) feature a broken promise implementation

They don't allow error handling well, and they don't mix and match with other implementations well.

However, since version 1.8 .then exists, which means you can kind of use the jQuery implementation as promises. This is an attempt to fix this bug and become more Promises/A compliant. There is an effort to improve interoperability, which is what the promises specification is all about anyway, the target of that effort is 2.2 and 1.12.

This means that from 2.2 onward, jQuery promises will be able to interop with other promise libraries, assimilate thenables like any promise library should, and behave less incorrectly according to the spec.

For all practical uses, you should consider another implementation.

There exist a lot of good promise implementation out there. Bluebird for example is fast ( much faster than jQuery promises), has a low memory footprint, has amazing stack traces and debugging support and interops seamlessly with jQuery promises and assimilates them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...