Skip to content

Commit

Permalink
Merge pull request #9 from sykeben/performance-upgrade-0
Browse files Browse the repository at this point in the history
Performance Upgrade #0 (Continued) has been merged.
  • Loading branch information
sykeben authored Apr 7, 2019
2 parents 5b9f501 + 6abc998 commit 4ca269b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions public/javascript/dash_0.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,18 @@ function setOnline(value) {
online = value;
}

// Make dash periodically update every second.
window.setInterval(periodicUpdate, 1000);
// Have dash update every second after finishing.
const setIntervalAsync = (fn, ms) => {
fn().then(() => {
setTimeout(() => setIntervalAsync(fn, ms), ms);
});
};

const delay = deplayMs => new Promise((resolve) => {
setTimeout(resolve, deplayMs);
});

setIntervalAsync(async () => { periodicUpdate(); await delay(1000); }, 1000);

// Make dash update upon load.
window.onload = periodicUpdate;
14 changes: 12 additions & 2 deletions public/javascript/dash_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,18 @@ function setOnline(value) {
online = value;
}

// Make dash periodically update every second.
window.setInterval(periodicUpdate, 1000);
// Have dash update every second after finishing.
const setIntervalAsync = (fn, ms) => {
fn().then(() => {
setTimeout(() => setIntervalAsync(fn, ms), ms);
});
};

const delay = deplayMs => new Promise((resolve) => {
setTimeout(resolve, deplayMs);
});

setIntervalAsync(async () => { periodicUpdate(); await delay(1000); }, 1000);

// Make dash update upon load.
window.onload = periodicUpdate;

0 comments on commit 4ca269b

Please sign in to comment.