Extractor.watch()

This commit is contained in:
2020-01-15 17:53:23 +08:00
parent 3338f78d91
commit 7644a1363f
6 changed files with 122 additions and 31 deletions

View File

@ -54,11 +54,22 @@ export class Extractor {
start() {
return this._startTasks(0);
}
stop() {
stop(id?: number) {
if (id !== undefined) {
id = this._checkTaskId(id);
if (id < 0) return;
this._tasks[id].stop();
return;
}
for (let i = 0; i < this._tasks.length; i++) {
this._tasks[i].stop();
}
}
watch(id: number) {
id = this._checkTaskId(id);
if (id < 0) return;
this._tasks[id].watch();
}
/**
* restart from specified task, but don't restart the previous tasks.
* @param {number} from where to restart the tasks, begins with 0
@ -138,7 +149,7 @@ ${exResults.toString(50) || "- Empty -"}
saveFile(exResults.toString(), "text/csv");
}
}
_checkTaskId(id: number, defaultId: number) {
_checkTaskId(id: number, defaultId?: number) {
if (!this._tasks.length) {
logger.info("No task found.");
return -1;