-
Notifications
You must be signed in to change notification settings - Fork 556
The Workflow EventEmitter
The workflow utility is just an EventEmitter with some attributes and methods that are common everywhere we use it. Specifically when handling CRUD operations. The EventEmitter pattern is one way to help stay out of callback hell.
Each request is unique for the user who's making it. However when you attach variables to app they can be shared between requests. You see app is referenced/linked during the request/response life-cycle as req.app and res.app.
For example in app.js you'll notice that we setup the workflow utility once.
...
app.utility.workflow = require('drywall-workflow');
...Now every request can get a new workflow quickly by just asking the app for a new one req.app.utility.workflow(req, res).
The workflows we create live and die during each request/response life-cycle, hence they are re-created when another subsequent request is made.
I hope this was helpful. If you have questions or think this page should be expanded please contribute by opening an issue or updating this page.