jstty / beelzebub

One hell of a Task Master!
http://beelzebub.io
Other
8 stars 4 forks source link

add interface transparency for tasks #37

Closed jstty closed 7 years ago

jstty commented 7 years ago
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');