Skip to content
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

_.partial support on constructors. #1704

Closed
jdalton opened this issue Jun 25, 2014 · 2 comments · Fixed by #1733
Closed

_.partial support on constructors. #1704

jdalton opened this issue Jun 25, 2014 · 2 comments · Fixed by #1733

Comments

@jdalton
Copy link
Contributor

jdalton commented Jun 25, 2014

Partial application is great and can be applied to constructors as well. For example:

function MyWidget(name, options) {
  // ..
}

MyWidget.prototype.get = function() { /*..*/ };

var MyWidgetWithCoolOpts = _.partial(MyWidget, _, {/*some options*/});

var widget = new MyWidgetWithCoolOpts('foo');
widget instanceof MyWidget // true
typeof widget.get // function

However, currently Underscore does not support this. It could if it shared a bit of the bind helper code to do the instanceof check.

@megawac
Copy link
Collaborator

megawac commented Jul 10, 2014

Something like megawac@0f4afd6 you're suggesting?

@jdalton
Copy link
Contributor Author

jdalton commented Jul 10, 2014

Yap.

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

Successfully merging a pull request may close this issue.

2 participants