import Dispatcher from 'ex-stream/Dispatcher';
Call executor with matched
inputData
import { createServer } from 'http';
import { dispatch } from 'ex-stream/Dispatcher';
const matcher = req => requestParser(req);
const executor = params => JSON.stringify(params);
createServer((req, res) => {
dispatch(matcher, executor)
.on(res)
}).listen(3000, 'localhost');
Parameters:
matcher
:function (inputData: *)
- function matchesinputData
and returnsmatchedData
executor
:function (matched: *)
- function executed withmatchedData
and returns value orPromise
that passed to stream
Creates Dispatcher stream instance
function matcher(inputData) {
// ...
}
function executor(matchedData) {
// ...
}
new Dispatcher(matcher, executor);
import { dispatch } from 'ex-stream/Dispatcher';
function dispatch(matcher, executor)