fundon

node v7 async await demo

  •  
  •   fundon · Oct 14, 2016 · 3368 views
    This topic created in 3673 days ago, the information mentioned may be changed or developed.
    5 replies  •  2016-10-14 10:15:12 +08:00
    doubleflower
    doubleflower
    Oct 14, 2016
    1
    要分清哪些调用是异步的,哪些不是好容易出错,应该加个默认强制。
    haozes
    haozes
    Oct 14, 2016
    2
    v7 还没发布吧
    fundon
    fundon
    OP
    Oct 14, 2016
    3
    @doubleflower 很好分清呀,`async` `await` 关键字一目了然
    doubleflower
    doubleflower
    Oct 14, 2016
    4
    @fundon 你有一大堆函数,在调用时你会分得清?除非你把每个 async 函数加上 async 前缀。

    比如

    xxx()
    await doThings()
    yyy()

    你忘了加 await 运行也不会报错,更搞的是不加 await 有时这段代码还能工作,太隐蔽的 BUG 啊。

    系统应该在调用 async 函数时不加 await 马上抛异常,或加上 nowait 标记,比如
    nowait doThing()
    fundon
    fundon
    OP
    Oct 14, 2016
    5
    @doubleflower 不报错,这点没问题,一个 Promise 没加 await 也是能够正常运行的。

    这个看人了,代码组织能力!要明确各个接口异步,同步情况。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2040 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 16:29 · PVG 00:29 · LAX 08:29 · JFK 11:29
    ♥ Do have faith in what you're doing.