load does not have access to request for other auto-loaded variables #31

Closed
jupiter opened this Issue Aug 18, 2011 · 5 comments

Comments

Projects
None yet
2 participants

jupiter commented Aug 18, 2011

In the example /forums/5/threads/12 the 'forum' can be loaded in the auto-loading load method. In the load method for a 'thread' there's no way to access the already loaded 'forum' - which could contain either neccesary information to load the 'thread', or could in fact contain the 'thread'.

At the moment, the load method should look like function (id, callback) {} I don't see the need for passing the id value, rather than the request. It only hides the key to the param containing the id. I realise that changing the arguments for this would break existing implementations and add a line of code to these implementations, e.g. var id = req.params.forum;, but I can't see another way.

Owner

tj commented Aug 18, 2011

yeah we could pass the request and make the sig (req, id, callback) or something

jupiter commented Sep 8, 2011

Yes, we could, but I wouldn't want to break existing implementations. The only way to not to do that would be to make the sig (id, callback, req). What do you think?

Owner

tj commented Sep 8, 2011

yeah im fine with that, passing the id is slightly useful "sugar" for simple cases I suppose, so I guess we dont have to remove it or move it for now

jupiter commented Sep 8, 2011

Actually, I just pulled and found that you've already implemented it in backward-compatible way. (I didn't even realise you could do fn.length to get the function's number of arguments.) Good job! Now it just needs to go into the documentation and into a release. Hope there's one soon. Thanks.

jupiter closed this Sep 8, 2011

Owner

tj commented Sep 8, 2011

haha yeah just saw that too, forgot we had it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment