Some bits for ReactJS-based client.

This commit is contained in:
Tomas Bures 2017-05-28 18:49:00 +02:00
parent 115d254baf
commit 4f52b571c9
27 changed files with 2326 additions and 202 deletions

View file

@ -0,0 +1,35 @@
'use strict';
const Promise = require('bluebird');
class WorkerCounter {
constructor() {
this.counter = 0;
}
enter() {
this.counter++;
}
exit() {
this.counter--;
}
async waitForEmpty() {
const self = this;
function wait(resolve) {
if (self.counter == 0) {
resolve();
} else {
setTimeout(wait, 500, resolve);
}
}
return new Promise(resolve => {
setTimeout(wait, 500, resolve);
})
}
}
module.exports = WorkerCounter;