// article on medium about this
// below are 2 independent running nodejs applications, which communicate using IPC
// process1.js
// This Process starts the pub-sub server, which other processes can connect to.
const ipc = require('node-ipc');
ipc.config.id = 'a-unique-process-name1';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.serve(() => ipc.server.on('a-unique-message-name', message => {
console.log(message);
}));
ipc.server.start();
// process2.js
const ipc = require('node-ipc');
ipc.config.id = 'a-unique-process-name2';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.connectTo('a-unique-process-name1', () => {
ipc.of['jest-observer'].on('connect', () => {
ipc.of['jest-observer'].emit('a-unique-message-name', "The message we send");
});
});