node-stepify icon indicating copy to clipboard operation
node-stepify copied to clipboard

为什么 我的这个task没有运行。

Open cos800 opened this issue 11 years ago • 5 comments

    var workflow = Stepify().debug(true);
    workflow
    .task('t1')
        .step('t1s1', function(){
            var root = this;
            setTimeout(function(){
                console.log('this is t1s1');
                root.done(null, 'i am from t1s1');
            }, 500);
        })
        .step('t1s2', function(a, b){
            var root = this;
            setTimeout(function(){
                console.log('this is t1s2');
                console.log('t1s2 arg a: '+a);
                console.log('t1s2 arg b: '+b);
            },500);

        }, 'i am from t1s2')
    .task('t2')
        .step('t2s1', function(){
            console.log('this is t2s1');
        })
    .run(['t1','t2']);

输出是:

app is running at port 3000
Task: t1 added.
Task: t2 added.
Start to run task: t1.
Start to run task: t2.
Start to run step: t1s1.
Start to run step: t2s1.
this is t2s1
this is t1s1
The step: t1s1 has done.
Start to run step: t1s2.
this is t1s2
t1s2 arg a: i am from t1s2
t1s2 arg b: i am from t1s1

但是没有输出 t2s1 这是为什么?

cos800 avatar Oct 17 '14 03:10 cos800

找到原理了,每个step都要调用 this.done() 或者 this.next() 。 对吧?

cos800 avatar Oct 17 '14 03:10 cos800

对的,表示你已经完成一部操作了

chemdemo avatar Oct 17 '14 07:10 chemdemo

谢谢~

cos800 avatar Oct 17 '14 07:10 cos800

哈哈 有问题随时交流哈

chemdemo avatar Oct 18 '14 05:10 chemdemo

还有一个issues,啥时候回复一下。。。 https://github.com/chemdemo/node-stepify/issues/4

cos800 avatar Oct 18 '14 06:10 cos800