官术网_书友最值得收藏!

Managing concurrency

Simplifying control flows has been a concern of the Node community since the very beginning of the project. Indeed, this potential criticism was one of the very first anticipated by Ryan Dahl, who discussed it at length during the talk in which he introduced Node to the JavaScript developer community.

Because deferred code execution often requires the nesting of callbacks within callbacks, a Node program can sometimes begin to resemble a sideways pyramid, also known as The Pyramid of Doom. You've seen it: deeply nested code, 4 or 5 or even more levels deep, curly braces everywhere. Apart from syntactical annoyances, you can also imagine that tracking errors across such a call stack might be difficult—if a callback at the third level throws, who is responsible for handling that error? The second level? Even if level 2 is reading a file and level 3 is querying a database? Does that make sense? It can be hard to make sense of asynchronous program flows.

主站蜘蛛池模板: 亳州市| 长丰县| 高雄市| 鹤庆县| 枣强县| 凉城县| 张北县| 西吉县| 思茅市| 玛多县| 迭部县| 海丰县| 扬州市| 卓尼县| 大庆市| 八宿县| 青浦区| 娱乐| 崇明县| 柳江县| 藁城市| 崇州市| 金华市| 长垣县| 台江县| 突泉县| 双鸭山市| 砚山县| 临潭县| 达尔| 天津市| 青冈县| 锦州市| 尼木县| 旬邑县| 湾仔区| 昌黎县| 洪洞县| 岗巴县| 玉树县| 治多县|