search

Home  >  Q&A  >  body text

node.js - bluebird中的.cancel方法

黄舟黄舟2822 days ago697

reply all(1)I'll reply

  • 阿神

    阿神2017-04-17 13:45:46

    默认情况下是关闭的,加上Promise.config({cancellation:true});这句即可。官方文档里有:

    .cancel js .cancel() -> undefined Cancel this promise. Will not do anything if this promise is already settled or if the Cancellation feature has not been enabled. See Cancellation for how to use cancellation.

    Cancellation Cancellation has been redesigned for bluebird 3.x, any code that relies on 2.x cancellation semantics won't work in 3.x. The cancellation feature is by default turned off, you can enable it using Promise.config.

    demo:

    结果

    reply
    0
  • Cancelreply