Skip to content

Conversation

@catwarrior
Copy link
Contributor

横向 纵向的比喻的感觉不太自然, 还不如直接点。

横向 纵向的比喻的感觉不太自然, 还不如直接点。
不难想象,如果依次读取多个文件,就会出现多重嵌套。代码不是纵向发展,而是横向发展,很快就会乱成一团,无法管理。这种情况就称为"回调函数噩梦"(callback hell)。

Promise就是为了解决这个问题而提出的。它不是新的语法功能,而是一种新的写法,允许将回调函数的横向加载,改成纵向加载。采用Promise,连续读取多个文件,写法如下。
Promise就是为了解决这个问题而提出的。它不是新的语法功能,而是一种新的写法,允许将回调函数的嵌套,改成链式。采用Promise,连续读取多个文件,写法如下。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

允许将回调函数的嵌套调用,改成链式调用

@ruanyf ruanyf merged commit 8be1572 into ruanyf:gh-pages Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants