procmux
a lightweight module to ease control flow and signaling between forked processes and their parents heavily inspired by Redux.
Install
npm i -S procmux
How to use
actionTypes.js - If this looks like Redux, thats because I jacked it.
const START = 'START'const STARTED = 'STARTED'const PROCESS = 'PROCESS'const PROCESSING = 'PROCESSING'const PROCESSED = 'PROCESSED'const STOP = 'STOP'
scheduler.js
This process schedules child processes via dispatching actions.
**DISPATCH => ACTIONS() => REDUCERS()
processor.js
This process is launched as a fork from its parent and should have no knowledge regarding its parent.
const mux = /** DROPPING MIDDLEWARE IN FAVOR OF mux.subscribe FOR INITIAL *//*mux.middleware(next => action => { const { type, payload } = action switch(type) { case START: start(payload) case PROCESS: process(payload) case STOP: stop(payload) } return next(action)})*/ mux const start = { /** start doing stuff */ mux} const process = { /** kick off some processing */ mux } const stop = { /** mux.exit triggers a process.exit but ensures the middleware and reducer get run with the exit status first. */ mux} /** handle special logic when this was run directly from command line (not forked). */ifmuxorphan