问题描述
在 Promises/A+ 标准中,我想知道一个承诺是否需要最终解决或拒绝.我的意思是承诺 X 具有在任何情况下都不会解决或拒绝 X 的属性.
承诺/A+状态
待处理时,承诺:
我.可能会转换为已完成或已拒绝状态.
可能的部分对我来说也是模棱两可的.我不知道是否应该将其理解为它可能转换但可能不会",或者它最终会转换并且可能转换为已完成或已拒绝.
不,规范没有强制要求这样做.兑现承诺需要多长时间没有限制.这包括无限长的时间 - 称为永不解决/永不解决承诺或永远待定承诺.(另请参阅承诺术语)
术语可能在这里被故意使用,并且确实带有传统含义.
甚至存在提供 Promise.never
原语的 promise 实现(例如在 creed) 来优化内存消耗,当您知道您的承诺不会兑现时.
In the Promises/A+ standard, I am wondering if a promise needs to resolve or reject eventually. By this I mean a promise X with the property that under no condition whatsoever will X get resolved or rejected.
Promises/A+ states
It is the may part that is the ambigious too me. I do not know whether to read it as saying "It may transition but may not" or that it will transition eventually and it may transition to fulfilled or rejected.
No, the spec does not mandate this. There is no restriction on how long a promise should take to settle. And that includes an infinitely long time - known as a never-resolving/never-settling promise or forever-pending promise. (see also promise terminology)
The term may is used deliberately here, and does carry the conventional meaning.
There even exist promise implementations that offer a Promise.never
primitive (e.g. in creed) to optimise the memory consumption for the case when you know that your promise won't settle.
这篇关于关于 Promises/A+ 规范,是否允许承诺永远不会解决或拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!