GithubHelp home page GithubHelp logo

How to escape async/await hell about blog HOT 8 OPEN

dwqs avatar dwqs commented on May 26, 2024 5
How to escape async/await hell

from blog.

Comments (8)

njleonzhang avatar njleonzhang commented on May 26, 2024 9

@dwqs 本来没看,你一说我去看了一下,和你这篇文章基本一个意思。
按我的理解,本质上这文章就是说用promise.all去实现多个异步请求并行,这东西早被说烂了。但是作者取了个高大上的名字叫async/await地狱,吸了一波眼球。
如果这种把并行异步写成串行的实现叫做地狱的话,用任何技术手段(callback, promise, rxjx)都能有这样的实现。
也就是说问题很普通,解法也很普通,名字高大上,所以有标题党之嫌。
我并没有怼你的意思,我只是吐糟一下这个国外大神。

你看下面的评论也有人这么说

1526780680436

image

最后感谢您的高产博客文章,很多让我受益匪浅。偶有吐槽,也不针对您,请不要介意。

from blog.

njleonzhang avatar njleonzhang commented on May 26, 2024 7

@dwqs 这个应该不是你的锅,这个作者应该就是这个意思。也许这个很多人并不知道(没注意)Promise.all或者并没有意识到这一点吧。毕竟业务里一般不会一次性去拿很多的detail信息。在并行请求不多的时候,一般感觉不出来差异。但是实际上,基本所有介绍async/await的文章对于这个用法都有明确的说明,我是不太明白这个作者一副发现新大陆的样子,冠以高大上的名字, 还有这么多点赞是什么意思, 233333333.

随便google下:
阮老师的async 函数的含义和用法
体验异步的终极解决方案-ES7的Async/Await

from blog.

njleonzhang avatar njleonzhang commented on May 26, 2024 4

原来并行的异步操作,写成串行的,好傻啊。:-) 这文章标题党啊

from blog.

dwqs avatar dwqs commented on May 26, 2024

@njleonzhang 你看了英文原文吗?

from blog.

dwqs avatar dwqs commented on May 26, 2024

@njleonzhang 我不是说你怼我 文章中列出的这种现象是客观存在的 19k+ 的赞同表明很多人都认可原作者的观点 并且可能很多人之前就是把「原来并行的异步操作,写成串行的」 我相信这种现象在国内也存在不少

标题党的原因可能是我的问题 标题我是直译过来的

from blog.

Dcatfly avatar Dcatfly commented on May 26, 2024

赞同 @njleonzhang 的观点。。这本质上并不是async、await的锅。。另外,forEach也可以解决文中的问题。

from blog.

php-cpm avatar php-cpm commented on May 26, 2024

熟悉js异步编程思维的开发者不会这么干,async、await 用的多的都是从其他语言转过来的服务端开发者,因为习惯同步执行的代码编写风格,按着这个思路事事滥用 async、await,才有了这篇文章

from blog.

njleonzhang avatar njleonzhang commented on May 26, 2024

@php-cpm 现在都流行这么写了啊。async、await 的代码看着还是挺舒服的。

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.