Hi Chris, thanks for your great patch and support, but it still does not work. I'm sure that I miss something in using asyncblock properly, but can't figure out what. I've updated the backbone-mongodb connector[1] with my most recent test and I would be extremely thankful if you would give a look at it.
I've used mocha tests to get everything checked. Basically, there is only one test that module that fails: model.js, and there are quite a few `console.log` statements left in the code just to see how it fails. On the other hand when I've moved out these codes into the module level, and used the same asyncblock calls. There it worked properly. thanks for your help Viktor [1]: https://github.com/ToolPartTeam/backbone-mongodb On márc. 5, 02:39, Chris Scribner <[email protected]> wrote: > 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
