I'm not sure if you were using asyncblock correctly or not, but it
wouldn't have worked even if you were.

The reason is that the backbone callbacks as you showed don't follow
standard node.js convention - as in they don't pass an error as the
first argument to the callback. I pushed a new update to asyncblock
just now (2.0.5) which adds support for this case if you set
firstArgIsError = false.

Here's a simple example of how it might look:

var findSomething = function(thing, callback){
    asyncblock(function(flow){
        flow.errorCallback = callback;
        flow.firstArgIsError = false;

        var nestwith = new nestAs();
        nestwith.find(
            { _id: x },
            { success: flow.set('found') }
        );

        var found = flow.get('found');

        callback(null, found);
    });
});

Something like that should work. Note that you can also set the
firstArgIsError when adding the callback, like flow.set({ key:
'found', firstArgIsError: false }), if you don't want it to apply to
all tasks added within that asyncblock. You can also use add / wait
instead of get/set, it doesn't matter.

You can't use the transform syntax because transformation assumes the
callback goes into the last parameter (like nestwith.find({ _id: x},
callback).

Hopefully this helps,

Chris

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

Reply via email to