UNPKG

791 BJavaScriptView Raw
1var define;
2if (typeof define === "undefined")
3 define = function (classInstance) {
4 classInstance (require, exports, module);
5 }
6
7define (function (require, exports, module) {
8
9var task = require('./base'),
10 util = require ('util');
11
12// this task emits
13
14var emitTask = module.exports = function(config) {
15
16 this.init (config);
17
18};
19
20util.inherits (emitTask, task);
21
22util.extend (emitTask.prototype, {
23
24 run: function () {
25 var self = this;
26
27 if (!self.$bind || !self.$bind.on || !(self.$bind.emit instanceof Function)) {
28 self.failed ('please provide $bind key in task configuration');
29 }
30
31 // completed must be called from message recipient
32 // TODO: add ability to detect is there any subscribers for such event
33 self.$bind.emit (self.scope, self);
34
35 }
36});
37
38return emitTask;
39
40});