jstty / beelzebub

One hell of a Task Master!

Home Page:http://beelzebub.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add interface transparency for tasks

jstty opened this issue · comments

commented
let Beelzebub = require('beelzebub');
let bz = Beelzebub();

class MyRealTasks extends Beelzebub.Tasks {
    task1 () {
       this.logger.log('MyRealTasks task1');
   }

   task2 () {
       this.logger.log('MySubTasks task2');
   }
}

class MyTaskInterface extends Beelzebub.Tasks {
    constructor (config) {
        super(config);
    }

    $beforeAll () {
        // this allows for dynamic interfacing base on configuration
        this.$isInterfactFor(MyRealTasks);
    }

    task1 () {
       this.logger.error('should be overriden');
    }

    task2 () {
       this.logger.error('should be overriden');
    }
}
bz.add(MyTaskInterface);
bz.run('MyTaskInterface.task1');