Created
October 4, 2013 16:33
-
-
Save d6y/6828791 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var deltaQueue = (function() { | |
| var timer = null; | |
| var q = []; | |
| var _self = {}; | |
| _self.add = function(delta) { | |
| timer && clearTimeout(timer); | |
| q.push(delta); | |
| timer = setTimeout(_self.doit, 100); | |
| }; | |
| _self.doit = function() { | |
| timer = null; | |
| var work = _.clone(q); | |
| q = []; | |
| offAir(function() { | |
| editor.getSession().getDocument().applyDeltas(work); | |
| }); | |
| }; | |
| return _self; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment