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 up https://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



________________________________

NOTICE: The information in this electronic mail transmission is intended by CoralTree Systems Ltd for the use of the named individuals or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.



--------------------------------------------------------------------------------


CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT

Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.