browser - Identify JavaScript synchronous execution block -
can't find discussion around that. in javascript, there way detect i'm running different functions in same execution block or have executed function in current execution block?
basically need optimize browser code avoiding run twice in same synchronous block. i'm doing this:
var issaved = false; function saveuistate() { if(issaved === true) { return; } // heavy dom processing ... issaved = true; settimeout(function() { // reset flag in execution block issaved = false; }, 0); }
but i'm not guaranteed flag reset before next execution block.
although node's process.nexttick
more appropriate, i'm more looking way identify execution block:
var lastexecutionblockid; function saveuistate() { if(lastexecutionblockid === executionblockid) { return; } lastexecutionblockid = executionblockid; ... }
you may want research mediator pattern, think in situation. subscribe calls , register events. mediator.js mediator pattern
Comments
Post a Comment