1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-26 14:38:19 +01:00

Remove usage of JX.defer in favor of setTimeout

Summary: -
Test Plan:
This was a pretty straightforward replace. Everything should
be sane.

Reviewed By: epriestley
Reviewers: tomo, epriestley, mroch
CC: aran, epriestley
Differential Revision: 803
This commit is contained in:
cpojer 2011-08-10 17:34:52 -07:00
parent e137080d9c
commit 7571d4c02a
7 changed files with 22 additions and 27 deletions

View file

@ -42,8 +42,7 @@ JX.install('PhabricatorShapedRequest', {
return; return;
} }
this._defer && this._defer.stop(); clearTimeout(this._defer);
var data = this._dataCallback(); var data = this._dataCallback();
if (this.shouldSendRequest(this._last, data)) { if (this.shouldSendRequest(this._last, data)) {
@ -52,10 +51,11 @@ JX.install('PhabricatorShapedRequest', {
this._callback(r); this._callback(r);
this._min = new Date().getTime() + this.getRateLimit(); this._min = new Date().getTime() + this.getRateLimit();
this._defer && this._defer.stop(); clearTimeout(this._defer);
this._defer = JX.defer( this._defer = setTimeout(
JX.bind(this, this.trigger), JX.bind(this, this.trigger),
this.getRateLimit()); this.getRateLimit()
);
})); }));
request.listen('finally', JX.bind(this, function() { request.listen('finally', JX.bind(this, function() {
this._request = null; this._request = null;
@ -64,9 +64,10 @@ JX.install('PhabricatorShapedRequest', {
request.setTimeout(this.getRequestTimeout()); request.setTimeout(this.getRequestTimeout());
request.send(); request.send();
} else { } else {
this._defer = JX.defer( this._defer = setTimeout(
JX.bind(this, this.trigger), JX.bind(this, this.trigger),
this.getFrequency()); this.getFrequency()
);
} }
}, },

View file

@ -39,7 +39,7 @@ JX.behavior('aphront-drag-and-drop', function(config) {
redraw(true); redraw(true);
// This redraws the instructions. // This redraws the instructions.
JX.defer(redraw, 1000); setTimeout(redraw, 1000);
}); });
drop.start(); drop.start();

View file

@ -173,10 +173,8 @@ JX.behavior('phabricator-object-selector', function(config) {
} }
last_value = cur_value; last_value = cur_value;
if (query_timer) { clearTimeout(query_timer);
query_timer.stop(); query_timer = setTimeout(sendQuery, query_delay);
}
query_timer = JX.defer(sendQuery, query_delay);
}); });
sendQuery(); sendQuery();

View file

@ -24,11 +24,10 @@ JX.behavior('phabricator-watch-anchor', function() {
} }
} }
JX.Stratcom.listen(
'hashchange',
null,
// Defer invocation so other listeners can update the document. // Defer invocation so other listeners can update the document.
function() { JX.defer(highlight); }); var fn = function() {
setTimeout(highlight, 0);
JX.defer(highlight); };
JX.Stratcom.listen('hashchange', null, fn);
fn();
}); });

View file

@ -42,7 +42,7 @@ JX.behavior('countdown-timer', function(config) {
JX.DOM.setContent(JX.$('phabricator-timer-minutes'), minutes); JX.DOM.setContent(JX.$('phabricator-timer-minutes'), minutes);
JX.DOM.setContent(JX.$('phabricator-timer-seconds'), seconds); JX.DOM.setContent(JX.$('phabricator-timer-seconds'), seconds);
JX.defer(calculateTimeLeft, 1000); setTimeout(calculateTimeLeft, 1000);
} }
}); });

View file

@ -8,10 +8,8 @@
JX.behavior('diffusion-jump-to', function(config) { JX.behavior('diffusion-jump-to', function(config) {
JX.defer( setTimeout(function() {
function() {
window.scrollTo(0, JX.$V(JX.$(config.target)).y - 100); window.scrollTo(0, JX.$V(JX.$(config.target)).y - 100);
}); }, 0);
}); });

View file

@ -98,8 +98,7 @@ JX.install('PathTypeahead', {
this._typeahead.listen( this._typeahead.listen(
'choose', 'choose',
JX.bind(this, function() { JX.bind(this, function() {
JX.defer( setTimeout(JX.bind(this._typeahead, this._typeahead.refresh), 0);
JX.bind(this._typeahead, this._typeahead.refresh));
})); }));
var repo_set_input = JX.bind(this, this._onrepochange); var repo_set_input = JX.bind(this, this._onrepochange);