Anyone have a sane and performant way that they break out of a domain or
action such as middleware? I am trying to design such behavior but am faced
with a multitude of interesting issues. The classic example of this problem
can be seen with Array.prototype.forEach (though this has the easier
synchronous execution for breaking):
```javascript
// we only want to print first 2 items
[1, 2, 3].forEach(function (item) {
if (item > 2) {
return;
}
console.log(item);
});
```
We often see the error first callback cause a fast fail on waterfall style
control flow, but what if we are not issuing an error, but rather a
terminating condition (making all middleware after it ignored)? Right now
my only solution is to add another callback to arguments ala:
```javascript
function finish(creds, finish, next) {
if (creds == 'secret') finish(null, 'user/mary');
else next(null, creds);
}
actor.perform('auth', creds, finish, next);
```
This seems, a bit... overkill to type out though. Anyways, looking for
suggestions.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en