Add support for work to be triggered via an event
This commit is contained in:
parent
c443b486cc
commit
f1544e5a8f
|
@ -21,6 +21,7 @@ var Cylon = module.exports = {
|
|||
Logger: Logger,
|
||||
Driver: require('./driver'),
|
||||
Adaptor: require('./adaptor'),
|
||||
Robot: Robot,
|
||||
Utils: Utils,
|
||||
|
||||
IO: {
|
||||
|
|
|
@ -230,11 +230,11 @@ Robot.prototype.initDevices = function(devices) {
|
|||
// Returns the result of the work
|
||||
Robot.prototype.start = function() {
|
||||
var begin = function(callback) {
|
||||
Logger.info('Working.');
|
||||
|
||||
this.emit('work', this);
|
||||
this.work.call(this, this);
|
||||
this.running = true;
|
||||
this.emit('working');
|
||||
|
||||
Logger.info('Working.');
|
||||
|
||||
callback(null, true);
|
||||
}.bind(this);
|
||||
|
|
|
@ -316,8 +316,8 @@ describe("Robot", function() {
|
|||
expect(robot.work).to.be.called;
|
||||
});
|
||||
|
||||
it("emits the 'working' event", function() {
|
||||
expect(robot.emit).to.be.calledWith("working")
|
||||
it("emits the 'work' event", function() {
|
||||
expect(robot.emit).to.be.calledWith("work")
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue