-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement mappingHint for wrapCallback, fixes #246 #247
Conversation
From the other issue thread:
Thoughts? |
That is a far better explanation of what mapping hint does than we have in the Stream Objects section of the docs, it might be worth updating there too. One thing I'd be worried about though is that we now have divergent behaviour for As for the optional arguments, normally I think they should be avoided as much as possible but given that currying is not an issue here there's probably an argument to be made for making an exception this time. |
I dunno about this...is it typical for node-style callback functions to pass in multiple values? I'm not sure the divergent behavior with The mapping hint thing was originally for event emitters. |
Off the top of my head, request has multiple arguments ( It seems to me that you won't necessarily want to use the same mapping hint for every function in an object you're p.s. Is there a particular reason |
@quarterto: I was trying to use 'request'. In the past I had problems with 'fs.exists' which has only one callback argument (no error argument, only a Boolean if the path exists or not). Btw., how else would I use a function like 'request' without 'wrapCallback'? 'consume' is the only solution I could find but this would be much more complex than just using 'wrapCallback' |
In request's case, it's actually a readable stream, so you could just do On
|
|
I was just wondering why that couldn't be put in |
Yeah, good point, I think that makes perfect sense. |
Cool, I'll open a separate pull request for that. Getting back on track: I don't think I'd expect |
Fair enough. No objections here from me then. Agreed that Regarding the default behavior, I think we should push an array if there are more than one success argument. You mentioned that it'd be weird if a callback was called with different arguments at different times, but that's more of a user problem, imo (they can provide a The benefit of this being that |
* callback (or an error) will be pushed onto the Stream. | ||
* returns a Highland Stream instead. | ||
|
||
* If no mapping hint is provided, only the first argument to the callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like @svozza said, maybe move this to the Stream Objects section and put a link to that section from here?
Yeah, as long as we document any gotchas between the two functions' behaviour I think we should go ahead with the PR. |
Now that I think about it, this PR is a breaking change. It's possible that someone is relying on the behaviour of Given that, I think we should wait until 3.0 for this. Collecting the todos here for future reference:
Anything I've missed? |
I still think you can put a version of the mappingHint documentation into the current branch's Stream Object section because it's far better than what's already there now. |
Good idea, I'll do that tonight. |
Can't we add |
Sure, if we're happy for it to go out without that? |
It wouldn't be any worse than what we have right now. |
9f1bfc2
to
e0c69f2
Compare
@vqvu was that all it needed? |
test.done() | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more test for wrapCallback with the default mapper and passing multiple values.
Looks good! |
I definitely think this is a useful thing to have (seems like an omission that it was only for EventEmitters and not
wrapCallback
too). Can someone check if the docs make sense to someone who isn't sleep-deprived?