Closed ortix closed 7 years ago
Hi, Thanks for your interest! You have 2 architectural choices here.
The first reason I made this module was to be able to build Express-like applications, but without Express. In that case, the complete flow of my application is managed by the middleware chain, and the app is just a sequence of middlewares interacting with the input
and the output
.
When you call handle
you can always pass a callback in the output object:
/**
* A function to be called when the chain is completed.
*/
const callback = (err, message) => {
if (err) {
return console.log(`An error occurred : ${err}`);
}
console.log(`Chain has completed : ${message}`);
};
// Starting a new chain.
chain.handle(input, { callback });
This way, in your middlewares you can call output.callback
when appropriate (an error happened, or the chain has successfully completed).
Hi, Did the answer help you ? In that case can I close the issue ?
Yes, sorry I didn't respond! You can close it
On Nov 1, 2017 12:54, "Halim Qarroum" notifications@github.com wrote:
Hi, Did the answer help you ? In that case can I close the issue ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HQarroum/middleware-chain/issues/7#issuecomment-341086146, or mute the thread https://github.com/notifications/unsubscribe-auth/ABbLWRfXOur_Mrml6Y56Mb6gqGNn0Palks5syFvfgaJpZM4QEW9p .
So when I handle the chain, how do I get the output of the chain after all the functions have been run?