可撤销承诺的状态 [英] Status of cancellable promises

查看:147
本文介绍了可撤销承诺的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://github.com/promises-aplus/cancellation-spec 上最旧的问题是(在写作时)9个月大。我真的找不到有关标准承诺的取消功能的可靠信息来源。



现在看起来这个功能在 bluebird ,但作为图书馆开发人员,我不想用完整的承诺来实现我的包裹。



我在哪里可以找到这些信息?

解决方案

可以承诺的承诺不会在ES6中,因为ES6承诺非常小。



在承诺/ A +空间中取消的工作已经停滞了,因为我们等待图书馆的发展来证明一种方法是显而易见的。最新的想法是这个问题,这是大多数图书馆想要的实施取消似乎遵循(或多或少)。要点是:




  • 作为拒绝的特殊情况取消

  • 取消反应传播向上在链中,拒绝本身向下传播。



不清楚你的意思是简单地传递一个承诺并支持取消规范。你是否试图生产可用的,假设你的图书馆的消费者会投下它,但是后来又以某种方式继承了一些取消行为?这有点棘手,特别是因为取消通常取决于用于拒绝承诺的指定的取消构造函数。如果取消生态系统更加发达,那么这样做的方式可能会更加直接。



对于未来,呃,它在不断变化!前进的一条路将是让人们在Promises / A +空间中夺取该取消建议的演进,从Q,RSVP,以及Bluebird等主要图书馆获得实施者的购买权。那么很多较小的图书馆可能会购买,你会有一些你可能依赖的东西。如果它证明是受欢迎的,那么可能会考虑到ECMAScript承诺!



但这取决于很多人在做很多工作,所以我们'看看是否发生:)。这是一个奇迹,它发生在基本的Promises / A +规范,但谁知道...它可能再次发生!


The oldest issue on https://github.com/promises-aplus/cancellation-spec is (at the time of writing) 9 months old. I really can’t found a reliable source of information about cancellation features on ‘standard’ promises.

By now looks like the feature is implemented in bluebird, but as a library developer I don’t want to clutter my package with a full promise implementation.

What I’d like to do is simply pass a promise-like and support the cancellation-spec.

Where could I find this information?

解决方案

Cancellable promises are not going to be in ES6, as ES6 promises are very minimal.

Work on cancellation in the Promises/A+ space has stalled, as we wait for library evolution to prove one approach clearly superior. The latest thinking is at this issue, which is what most libraries looking to implement cancellation seem to follow (more or less). The key points are:

  • Cancellation as a special case of rejections
  • Reactions to cancellation propagate upward in the chain, as well as the rejection itself propagating downward.

It's not clear what you mean by "simply pass a promise-like and support the cancellation-spec." Are you trying to produce thenables, under the assumption that consumers of your library will cast it, but somehow inherit some cancellation behavior afterward? That'd be a bit tricky, especially since cancellation generally depends on a specified Cancellation constructor used for rejecting the promise. If the cancellation ecosystem was more developed, the way to do this would likely be more straightforward.

As for the future, well, it's in flux! One route forward would be for someone to champion an evolution of that cancellation proposal in Promises/A+ space, getting implementer buy-in from major libraries like Q, RSVP, when, and Bluebird. Then a lot of the smaller libraries would likely buy in, and you'd have something you could probably depend on. If it proves that popular, it'd probably be considered for ECMAScript promises as well!

But that depends on a lot of people doing a lot of work, so we'll see if it happens :). It was kind of a miracle for it to happen with the base Promises/A+ spec, but who knows... it could happen again!

这篇关于可撤销承诺的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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