3 ms·
This is something I tried last NodeJS system I wrote. I ended up with dozens more function definitions elsewhere in the code. Those functions were bizarre littl
by lnanek2 13y ago
This is something I tried last NodeJS system I wrote. I ended up with dozens more function definitions elsewhere in the code. Those functions were bizarre little things that only ran in a very specific context when several other things were in progress. Defining your callback functions separately just leads to an unmaintainable mess.
It isn't the language I use, but C# really handled this whole situation best with async/await. There you can just keep coding along in the main narrative of execution that you are concerned about even if it means under the hood the code execution stops and other things are done until your await statement continues. The error flow can usually be handled with some sort of exception mechanism. This article and the traditional pyramid of death are both really just hacks to get around lack of a language change like async/await.