jeffbski/react — Issue #3: add new function that executes flow immediately
Author: mvolkmann
Created: 2012-02-07 16:09:28+00:00
State: open

Here's an example where I would use this:

````
var doIt = react('doIt', 't, cb -> err',
loadData, 'cb -> err',
getRiceCourses, 't, true, cb -> err, urls', {name: 'urls', after: loadData},
getRiceCourses, 't, false, cb -> err, entities', {name: 'entities', after: loadData},
compareResults, 't, urls, entities, cb -> err', {after: ['urls', 'entities']},
helper.shutdown, 'cb -> err', {name: 'shutdown', after: ['urls', 'entities']});

doIt(t, function (err) {
t.notOk(err, err || 'REST API with multiple matches');
t.end();
});
````

Suppose the new function is called "act". I would use it like this:

````
act('t, cb -> err',
loadData, 'cb -> err',
getRiceCourses, 't, true, cb -> err, urls', {name: 'urls', after: loadData},
getRiceCourses, 't, false, cb -> err, entities', {name: 'entities', after: loadData},
compareResults, 't, urls, entities, cb -> err', {after: ['urls', 'entities']},
helper.shutdown, 'cb -> err', {name: 'shutdown', after: ['urls', 'entities']},
function (err) {
t.notOk(err, err || 'REST API with multiple matches');
t.end();
});
````

Note that I didn't need to name the function I was creating and I added the callback as the last function in the flow.