@extjs/sencha-cmd-linux-32
Version:
Productivity and performance optimization tool for building applications with Sencha Ext JS and Sencha Touch.
38 lines (31 loc) • 711 B
JavaScript
;
class Ready {
constructor() {
this.blocks = 0;
this.listeners = [];
}
block() {
this.blocks++;
}
unblock() {
if (this.blocks && !--this.blocks) {
this.fireReady();
}
}
fireReady() {
for (var i = 0; i < this.listeners.length; i++) {
var listener = this.listeners[i];
listener();
this.listeners[i] = null;
}
this.listeners = Fashion.filter(this.listeners, (l) => !!l);
}
onReady(callback) {
if (!this.blocks) {
callback();
} else {
this.listeners.push(callback);
}
}
}
module.exports = Ready;