On Sat, Feb 22, 2014 at 12:46 AM, Aria Stewart wrote:
> On Fri, Feb 21, 2014 at 07:37:34PM -0800, Jan Krems wrote:
> > For me one of the most powerful things about promises is that they can 
be
> > passed around, returned from functions, etc.. It seems like your way of
> > handlings errors prevents this. Or at least makes it very dangerous

Perfectly safe unless you want to reenter the event loop before you

> actually deal with them. Which, yes, generators. Actually, this makes

> me think that for promisables anyway, attaching a catch after

> reentering the event loop should probably be an error. Possibly

> attaching any then/catch/finally/() actually. Hmm...

>
I agree that this does remove some of the purity of the basic premise

> of futures/promises, but I'm not sure it actually causes practical

> issues.

> Why not
>
>     function appendComment(id) {
>         var user = db.load('user'),
>             thread = db.load('thread'),
>             comments = thread.thenPromise(function(R, th) { 
R(th.getComments()); });
>
>         return [user, thread, comments];
>     }
>
> instead, returning the promises -- no generator. If you're deferring error
> handling to the caller, do it completely rather than mixing modes?

I would rewrite the original as:

>
    function appendComment(id) {
        var user = dbHandle.load('user', { id: 'jen' });
        var thread = dbHandle.load('thread', { id: 1 });

>         return thread.getComments().then(function(comments){

>             // more code

>         });

>     }

>     appendComment(23)

>         .catch(function(E){ /* do something with error */ )};

> But it is a good point: promises that force you to handle errors don't 
play
> that nicely when you enter the event loop before setting up the error 
handling.
> What would your use case there be? What would error handling look like if 
you
> used non-enforcing promises?

As Aria says, outside of generators, I'd be very interested in hearing

> a use case for then/catch/etc on nextTick.  Unsurprisingly, to me, it
sounds harmful not helpful. =p
 

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to