6 ms·
I recently read a chapter of David Herman's Effective JavaScript[1] that talked about preserving the async contract even if you cache results (ie. can return wi
by aninimus 13y ago
I recently read a chapter of David Herman's Effective JavaScript[1] that talked about preserving the async contract even if you cache results (ie. can return without an async call from the caller). Try:
if (connectionInstance) {
setTimeout(function(){callback(connectionInstance)}, 0);
return;
}
That way your async functions will always behave the same way.
[1] http://effectivejs.com/ http://effectivejs.com/
- afshinmeh 13y agoOr maybe with process.nextTick.