emit
data
event is used to return the results of the component execution.
Here an example how it can be used:
function emitData() {
this.logger.info('About to say hello to ' + name + ' again');
var body = {
greeting: name + ' How are you today?',
originalGreeting: msg.body.greeting
};
var data = messages.newMessageWithBody(body);
self.emit('data', data);
}
Here is anouther example of usage:
function emitData(result) {
this.logger.info("Emitting data");
var body = result.body;
this.logger.info(_.pick(body, ['sku', 'quantityOnStock']));
var msg = messages.newMessageWithBody(body);
self.emit('data', msg);
}