• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Sin
V2EX  ›  程序员

有在生产环境里用上 JavaScript 里的 async/await 的没?

  •  
  •   Sin · Apr 26, 2016 · 3549 views
    This topic created in 3668 days ago, the information mentioned may be changed or developed.
    除了 babel 编译出的代码没法看以外还有什么其他坑不?
    11 replies    2016-04-26 21:27:27 +08:00
    morethansean
        1
    morethansean  
       Apr 26, 2016 via iPhone
    编译的代码不本来就不是给你看的?要看不是有 source map 么?
    bertonzh
        2
    bertonzh  
       Apr 26, 2016
    async/await 编译成 generator 之后可读性还行啊,相当于 co/yield
    除非你是编译成 ES5 ?只有前端项目才需要编译成 ES5 吧。但是前端项目需要使用 await 进行异步控制的并不多见。
    learnshare
        3
    learnshare  
       Apr 26, 2016
    生成的代码不是给人看的,何必纠结这个
    plantain
        4
    plantain  
       Apr 26, 2016 via Android
    我在 nodejs 里用过,通过 ts 转换成 es6 的 generator/yield 形式。
    遇到过,写在 lodash.each 里不会等待的问题,改成 for...of 后就好了。还有好多坑,不过都能好解决。
    plqws
        5
    plqws  
       Apr 26, 2016
    后端还有 Electron 直接配合 Babel 用上了,前端还不太敢…
    zwh8800
        6
    zwh8800  
       Apr 26, 2016
    有一些小项目用上了,暂时没遇到什么坑。
    hxtheone
        7
    hxtheone  
       Apr 26, 2016
    ES6/7 只用了 Promise, 表示目前没有遇到任何坑, 相当爽
    murmur
        8
    murmur  
       Apr 26, 2016
    我们要兼容 IE8 ,还不敢用 e6 e5 都得小心着点
    echo1937
        9
    echo1937  
       Apr 26, 2016
    @murmur 真心疼你们。
    sox
        10
    sox  
       Apr 26, 2016 via Android
    node 应用用原生的 ES6 支持 + co

    前端应用用 ES6 + Stage 0 😂
    magicdawn
        11
    magicdawn  
       Apr 26, 2016
    http://v2ex.com/t/269910#reply9

    co.wrap 跟 async function 一样啊, 手动做下 babel async-to-generator 这个工作
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5734 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 161ms · UTC 01:44 · PVG 09:44 · LAX 18:44 · JFK 21:44
    ♥ Do have faith in what you're doing.