关于Promises / A +规范,承诺永远不会解决或拒绝吗? [英] Regarding Promises/A+ Specification, is a promise ever allowed to never resolve or reject?

查看:71
本文介绍了关于Promises / A +规范,承诺永远不会解决或拒绝吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Promises / A +标准中,我想知道承诺是否需要解决或拒绝最终。我的意思是承诺X的财产,在任何条件下都不会解析或拒绝X.

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 + state



  1. 等待时,承诺:

  1. When pending, a promise:

i。可以转换到已履行或被拒绝的状态。

i. may transition to either the fulfilled or rejected state.


这是可能部分也是我的暧昧。我不知道是否将其视为它可能转换但可能不会或者它最终会转换,它可能会转换为已履行或被拒绝。

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.

甚至存在提供 Promise.never 原语的promise实现(例如在信条)当你知道你的承诺不会解决时,优化案件的记忆消耗。

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 +规范,承诺永远不会解决或拒绝吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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