Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

The Workflow EventEmitter

Reza Akhavan edited this page Jan 22, 2014 · 1 revision

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.

Use the Force

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.