Leaky Functional Bucket
To combine multiple calls to one function into one call (after all others are finished), use setTimeout to break out of the current call stack!
function collector() {
collector._count = collector._count || 0;
if (!collector._count) {
setTimeout(function() {
target();
collector._count=0;
}, 0);
}
collector._count++;
}
Written by Alex Lee
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#