Device1
Device1.prototype.init = function(config) {
config
.type('device')
.state('START')
.name('my-device1');
config
.when('START', { allow: ['start']})
.when('END', { allow: ['end']})
.map('start', this.start)
.map('end', this.end);
};
Device1.prototype.start = function(cb){
***********************************************
this.state = 'END';
cb();
};
Device1.prototype.end = function(cb){
this.state = 'START';
cb();
};
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Device2
Device2.prototype.init = function(config) {
config
.type('device')
.state('OFF')
.name('my-device2');
config
.when('OFF', { allow: ['turn-on']})
.when('ON', { allow: ['turn-off']})
.map('turn-on', this.turnOn)
.map('turn-off', this.turnOff);
};
Device2.prototype.turnOn = function(cb){
this.state = 'ON';
cb();
};
Device2.prototype.turnOff = function(cb){
this.state = 'OFF';
cb();
};
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Is it possible to call Device2 transaction turnOn from the ************************ marked place in Device1?