Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-08 Thread Bradley Meck
Completely agree that not having the default action at the end would cause issues in a single middleware stack. I use middleware trees rather than single stack with Understudy, it would go to the end of an action (for example the default action such as just closing the HTTP request). I run

Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-08 Thread Jake Verbaten
Sounds like you want a pull stream to me. You pull from the data until you dont need it anymore and then stop pulling. Which can be contrasted to a push stream which will continue pushing at you forcing you to do an if check and just ignore the excess data. So I think the issue is your trying to

Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-08 Thread Bradley Meck
I am not sure I understand the use of a pull stream in this context. Can you explain in a small example of how to use a stream instead of domains/middleware/etc. in this fashion for control flow? On Tuesday, January 8, 2013 3:59:29 AM UTC-6, Raynos wrote: Sounds like you want a pull stream to

[nodejs] Convention to preemptively break out of a domain/action?

2013-01-07 Thread Bradley Meck
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

Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-07 Thread Isaac Schlueter
On Mon, Jan 7, 2013 at 7:47 AM, Bradley Meck bradley.m...@gmail.com wrote: ```javascript // we only want to print first 2 items [1, 2, 3].forEach(function (item) { if (item 2) { return; } console.log(item); }); ``` More efficient, especially for long lists: ```javascript [1,

Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-07 Thread Bradley Meck
This is good, gets me thinking. This brings up that there are 2 styles of approaching this issue: abort style - manually cause the action to fast fail condition style - provide a condition to check on every step of the action May help others thinking about this as well to think of both

Re: [nodejs] Convention to preemptively break out of a domain/action?

2013-01-07 Thread Marco Rogers
Condition style is always available as an option. But in the types of situations you're describing, where you actually want to end the execution early, you end up using condition style because abort style does not exist. That's the case with array.forEach, and it's one of the reasons array.some