md-curcuma
Version:
A Typescript library for transporting and converting markdown and other data.
61 lines (60 loc) • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Runner = void 0;
class Runner {
constructor() {
this.tasks = [];
this.reader = null;
this.writer = null;
}
addTask(task) {
this.tasks.push(task);
}
addReader(reader) {
this.reader = reader;
}
addWriter(writer) {
this.writer = writer;
}
do_command(props) {
if (props.to === "runner" &&
props.command === "perform-tasks") {
console.log("### runner.do_command received props: ", props.from, props.to, props.command);
for (let task of this.tasks) {
task.add_observer(this, this.get_observer_id());
task.perform(props.dao);
}
if (this.writer != null) {
this.writer.write(props.dao);
}
}
else if (props.to === "runner" &&
props.command === "do-not-io-write") {
}
else if (props.to === "runner" &&
props.command === "tasks-finished") {
console.log("################## FERTIG, FÜHRE WRITE AUS!!!");
if (this.writer != null) {
}
else {
console.log("Du hast keinen writer definiert!");
}
}
else {
console.log("runner.do_command received UNKNOWN props: ", props.from, props.to, props.command);
}
}
run() {
if (this.reader != null) {
this.reader.add_observer(this, "runner");
this.reader.read();
}
else {
console.log("Du hast keinen reader definiert.");
}
}
get_observer_id() {
return "runner";
}
}
exports.Runner = Runner;