@benev/praxis
Version:
Multiplayer webgame laboratory
23 lines • 586 B
JavaScript
import { Hex } from "@e280/stz";
const notDone = Symbol("notDone");
export class Task {
label;
progress;
id = Hex.random(32);
promise;
#payload = notDone;
constructor(label, progress, promise) {
this.label = label;
this.progress = progress;
this.promise = promise.then(p => {
this.#payload = p;
return p;
});
}
get payload() {
if (this.#payload === notDone)
throw new Error(`task not done "${this.label}"`);
return this.#payload;
}
}
//# sourceMappingURL=task.js.map