This repository has been archived on 2025-10-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gekko/plugins/childToParent.js
T
2021-06-06 20:25:14 +02:00

24 lines
634 B
JavaScript

// Small plugin that subscribes to some events, stores
// them and sends it to the parent process.
const log = require('../core/log');
const _ = require('lodash');
const subscriptions = require('../subscriptions');
const config = require('../core/util').getConfig();
const ChildToParent = function() {
subscriptions
// .filter(sub => config.childToParent.events.includes(sub.event))
.forEach(sub => {
this[sub.handler] = (event, next) => {
process.send({type: sub.event, payload: event});
if(_.isFunction(next)) {
next();
}
}
}, this);
}
module.exports = ChildToParent;