|
Hello
Callback hell has been mentioned a few times (mainly by Nathan) and it is something that has been bugging me recently because I have indeed fallen into this trap. It is also known as the "pyramid of doom" because your code can end up looking like an ever increasingly complicated list of nested function calls.
However, mainly because Sails uses it "out of the box", I have educated myself in the use of "Promises". Promises allow you to write your asynchronous code in a synchronous way, such that callback hell can be eliminated.
I won't go into the details here, but if you are interested, look uphttps://github.com/kriskowal/q
Waterline ORM also uses a promises library called "bluebird":http://bluebirdjs.com/docs/getting-started.html
I have refactored a lot of horrific code now that I have a grip on this technique.....promises are beautiful thing!
Kevin
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.