Skip to content

Instantly share code, notes, and snippets.

@d6y
Created October 4, 2013 16:33
Show Gist options
  • Select an option

  • Save d6y/6828791 to your computer and use it in GitHub Desktop.

Select an option

Save d6y/6828791 to your computer and use it in GitHub Desktop.
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