是否有任何 jQuery 版本符合 Promise/A 规范? [英] Is any jQuery version compliant to Promise/A specifications?

查看:23
本文介绍了是否有任何 jQuery 版本符合 Promise/A 规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了几篇文章后,我开始知道 jQuery 中有 promise 实现.但我不确定是否有任何版本的 jQuery 符合 Promise/A.

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.

推荐答案

2015 年更新:jQuery 3.0 与 Promises/A+ 兼容.请参阅 GitHub 上的此问题,因此 3.0 测试版与 3.0 兼容,当 3.0 发布时,它也会兼容.在此之前 - 以下内容仍然适用.

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.

它们不能很好地处理错误,也不能很好地与其他实现混合和匹配.

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

然而,自 1.8 版.then 存在,其中意味着您可以使用 jQuery 实现作为承诺.这是尝试修复这个错误并成为更多承诺/A合规.努力提高互操作性无论如何,这就是承诺规范的全部内容,该努力的目标是 2.2 和 1.12.

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.

这意味着从 2.2 开始,jQuery promises 将能够与其他 promise 库互操作,像任何 promise 库一样吸收 thenables,并减少根据规范的错误行为.

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.

那里有很多好的承诺实现.例如,Bluebird 速度快(比 jQuery 承诺快得多)、内存占用低、具有惊人的堆栈跟踪和调试支持以及与 jQuery 承诺无缝互操作并吸收它们.

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.

这篇关于是否有任何 jQuery 版本符合 Promise/A 规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆