JavaScript
Create a component
const txjs = require('rx-txjs');
/**
* a simple component register it's mountpoint after tne name 'COMPONENT'
*
* To communicate with the component do:
*
* let mp = txjs.TxMountPointRegistry.instance.get('COMPONENT');
* mp.next(new TxTask('test', 'status', data = {}));
*/
class Component {
constructor() {
this.mountpoint = txjs.TxMountPointRegistry.instance.create('COMPONENT');
this.mountpoint.tasks().subscribe(
(task) => {
console.log('[G2Component:tasks] got task = ' + JSON.stringify(task, undefined, 2));
this.mountpoint.reply().next(new txjs.TxTask('Component', '', task['data']));
}
)
}
}
module.exports = new Component();
Last updated