mirror of https://codeberg.org/pzp/pzp-db.git
22 lines
336 B
JavaScript
22 lines
336 B
JavaScript
class ReadyGate {
|
|
#waiting
|
|
#ready
|
|
constructor() {
|
|
this.#waiting = new Set()
|
|
this.#ready = false
|
|
}
|
|
|
|
onReady(cb) {
|
|
if (this.#ready) cb()
|
|
else this.#waiting.add(cb)
|
|
}
|
|
|
|
setReady() {
|
|
this.#ready = true
|
|
for (const cb of this.#waiting) cb()
|
|
this.#waiting.clear()
|
|
}
|
|
}
|
|
|
|
module.exports = { ReadyGate }
|