There are following solutions to fight callbacks (my personal opinion in brackets):
0. callback hell (simple and good to for working with concurrency, but too verbose to be usable in day to day work when in 99% of cases you work with plain sequential logic) 1. statemachine hell (when you trade callbacks hell to bunch states & named functions, just a little better than callback hell, most frequently advised approach, a little better than callback hell) 2. async helpers (just a little better, but still far from being simple) 2. generators (simple, and seems to be good one, although, seems there are some gotchas with robust error handling) 3. code generation (some tools are good, but most are not, also there may be gotchas with error handling). 4. fibers (resulting code is simplest, it is exactly the same as plain synchronous, works in 99.99% of cases, handles errors almost perfectly, but, in 0.01% you need to be careful and know what you are doing). On Saturday, 19 April 2014 03:47:10 UTC+4, Alex Kocharin wrote: > > > It's someone trying to sell another javascript-like language as an answer > to this simple problem. :) > > If you have 20 subsequent functions, you can use generators, that's what > they are good at. > > > 19.04.2014, 01:46, "Kevin Burton" <[email protected] <javascript:>>: > > What is the '_' is that some special character to get it to run > synchronously? > > On Friday, April 18, 2014 4:31:59 PM UTC-5, Bruno Jouhier wrote: > > a(_); > b(_); > c(_); > > Bruno > > On Friday, April 18, 2014 8:52:16 PM UTC+2, Kevin Burton wrote: > > Alex, I think in this case I need to. I have about 20 functions to > execute, each of which depends on the side-effects of the previous > function. I can basically make it synchronous by making what looks like a > big 'V' > > a(function(err) { > if(err) { > . . . . . > } else { > b(function(err) { > if(err) { > } else { > c(function(err) { > if(err) { > } else { > > } > }); > } > }); > } > }); > > On Friday, April 18, 2014 11:34:41 AM UTC-5, Alex Kocharin wrote: > > > 18.04.2014, 19:24, "Kevin Burton" <[email protected]>: > > I notice that simply leaving off the callback or making a callback null > doesn't always make a node function synchronous. What is a good general > pattern for making a node method synchronous (assuming the source for the > method is available)? > > > > A usual advice about making a node method synchronous is "don't do that". > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
