actionx
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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);
}

Package Sidebar

Install

npm i actionx

Weekly Downloads

3

Version

1.0.2

License

none

Unpacked Size

22.4 kB

Total Files

7

Last publish

Collaborators

  • ifyx