Answer the question
In order to leave comments, you need to log in
How to "soften" the impact of callbacks in JS?
There are no particular difficulties in asynchronous programming and programming in JS, but as the project grows, it becomes necessary to execute several asynchronous requests within the same context at once (especially relevant for Node.js), and it happens that already on the third nesting, brackets and everything else to anonymous callbacks start to be an eyesore.
For example:
do.smth1(function(arg1){
////code
////code
////code
do.smth2(function(arg2){
////code
////code
////code
do.smth3(function(arg3){
////code
////code
////code
});
});
});
Answer the question
In order to leave comments, you need to log in
It 's
strange that no one has suggested
https://learn.javascript.ru/generator#library-co
https://www.npmjs.com/package/co
" functions via yield fun(...)
Promises or make a separate function/method for each callback.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question