4.1.0 • Published 7 months ago
@xmcl/task v4.1.0
Task Module
This is a helper module for Minecraft Launcher. See the github home page for more information.
Usage
Progress Moniting
You can use @xmcl/task
model to track the progress of a task. In the launcher, they are majorly download task.
This module implements a basic object model for task with progress. The task can be paused or cancelled.
import { Task, TaskBase, task } from "@xmcl/task";
class ATask extends TaskBase {
// implement a task
}
class BTask extends TaskBase {
// implement a task
}
// suppose you have such task
const myTask = task("hello", function() {
await this.yield(new ATask().setName("world"));
await this.yield(new BTask().setName("xmcl"));
});
// start a task
const result = await task.startAndWait({
onStart(task: Task<any>) {
// the task path is the task name joined by dot (.)
const path = task.path;
console.log(`${path} started!`);
},
onUpdate(task: Task<any>, chunkSize: number) {
// a task update
},
onFailed(task: Task<any>, error: any) {
// on a task fail
},
onSucceed(task: Task<any>, result: any) {
// on task success
const path = task.path;
console.log(`${path} ended!`);
},
// on task is paused/resumed/cancelled
onPaused(task: Task<any>) { },
onResumed(task: Task<any>) { },
onCancelled(task: Task<any>) { },
});
// the result will print like
// hello started!
// hello.world started!
// hello.world ended!
// hello.xmcl started!
// hello.xmcl ended!
// hello ended!
4.1.0
7 months ago
4.0.6
11 months ago
4.0.5
1 year ago
4.0.4
1 year ago
4.0.3
2 years ago
4.0.2
2 years ago
4.0.1
3 years ago
4.0.0
3 years ago
3.0.0
3 years ago
2.2.0
4 years ago
2.1.8
4 years ago
2.1.7
4 years ago
2.1.6
4 years ago
2.1.5
4 years ago
2.1.4
4 years ago
2.1.3
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.1-alpha.1
4 years ago
2.0.1-alpha.0
4 years ago
2.0.0-alpha.0
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.2
4 years ago
1.0.3
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago
0.2.0
5 years ago
0.1.3
5 years ago
0.1.2
5 years ago
0.1.1
5 years ago
0.1.0
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago