actionx
v1.0.2
Published
基于动作的分块执行。
Downloads
3
Readme
actionx
基于动作的分块执行。
支持序列执行 支持异步执行 基于状态的变化
示例
class ActionX extends ActionBase {
/** 需要重写的执行方法 */
protected onExecute() {
super.onExecute();
console.log('execute Action', this.uid);
setTimeout(() => {
this.finish();
}, 5000);
}
}
const action1 = new ActionX();
const action2 = new ActionX();
const action3 = new ActionX();
action1.on('ActionCompleted', ActionCompleted);
action2.on('ActionCompleted', ActionCompleted);
action3.on('ActionCompleted', ActionCompleted);
const process = new ProcessBase();
process.add(action1);
process.add(action2);
process.add(action3);
process.on('ProcessCompleted', () => {
console.log('ProcessCompleted');
});
process.start();
function ActionCompleted(action: IAction) {
console.log('ActionCompleted', action.uid);
}