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

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.

主站蜘蛛池模板: 云阳县| 南木林县| 忻州市| 浦江县| 永州市| 灵川县| 镇原县| 平谷区| 枣庄市| 内丘县| 舒城县| 桐梓县| 郓城县| 贵州省| 治多县| 屏南县| 抚州市| 德州市| 微山县| 邵武市| 离岛区| 盐津县| 拉萨市| 陵水| 大荔县| 宁陵县| 绥芬河市| 云林县| 邓州市| 长阳| 肇州县| 施甸县| 赤峰市| 拜城县| 丽水市| 池州市| 通山县| 洛阳市| 广南县| 都江堰市| 巴林右旗|