Always ground your exposed callbacks
Always ground the callbacks that your API is exposing. If the consumer throws an exception, it will bubble up to your stack preventing further execution.
// ground callback exceptions
try{callback(true);}catch(ex){}
// ... or this part will never be reached
defer.resolve(true);
Written by Thanasis Polychronakis
Related protips
1 Response
Food for thoughts:
http://jsperf.com/catched-callback
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Promises
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#