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

Offers a way to mix-in generators #733

Closed
SBoudrias opened this issue Jan 10, 2015 · 2 comments
Closed

Offers a way to mix-in generators #733

SBoudrias opened this issue Jan 10, 2015 · 2 comments

Comments

@SBoudrias
Copy link
Member

ATM the only built-in way to reuse functionalities with Yeoman is inheritance:

var BaseGen = generator.Base.extend();
var myGenerator = BaseGen.extend();

That's fine, but it's hard to share multiple decoupled functionalities as prototypes only support single inheritance.

We could offer a way to easily mix-in functionalities in Yeoman. That's the API I have in mind:

var mixin = require('yeoman-mixin');

var myMixin = mixin({
  prompting: function () {},
  _someMethod: function () {}
});

var Generator = generator.Base.extend({
  prompting: function () {}
});
myMixin.mix(Generator);

Which would basically results in:

Generator.prototype.prompting.prompting1 = function () {};
Generator.prototype.prompting.prompting2 = function () {};
Generator.prototype._someMethod = function () {};

This can be done pretty easily. I wonder if we should make it more complex by separating scope between mixins and original prototype or something like that... Maybe something to consider later on?

@arthurvr
Copy link
Member

I like that idea! 👍

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2020

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 2, 2020
@github-actions github-actions bot closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants