每次尝试更改进度时,我都试图调用一个方法(将在初始化后声明)
class Task {
Constructor(){
this.DoTask();
}
// I want to set this outside class after the instance is created
public OnProgress(p: number){}
public DoTask(){
prog = progress({}, this.OnProgress.bind(this));
// the task is being performed here
...
.pipe(prog)
.RemainingOFTransforms()
}
}
const MyTask = new Task();
MyTask.OnProgress = (p: number) => {
console.log(p) // this should log all the progress numbers as it is constantly changing
}
我希望每次更改进度时都会调用MyTask.OnProgress,但只会调用一次