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

app.mixin() #68

Closed
jonathanong opened this issue Nov 4, 2013 · 9 comments
Closed

app.mixin() #68

jonathanong opened this issue Nov 4, 2013 · 9 comments

Comments

@jonathanong
Copy link
Member

since we will have app.context(), app.request(), and app.response(), i guess we should have something like app.mixin() where you can do:

app.mixin({
  context: {},
  request: {},
  response: {}
})

so you can do with a plugin:

app.mixin(require('koa-context-something'))

maybe app.plugin(). maybe a different, better name. also, an app.inherit(parentapp) would be nice as well, especially if you mount apps.

@tj
Copy link
Member

tj commented Nov 6, 2013

for the most part subapps won't collide, if people build subapps that are meant to be mounted to any application I'd definitely suggest that they shouldn't be doing prototype manipulation anyway so I think we can skip that part. It's tempting to even remove app.context() for now and just encourage modularity via foo(this), it's not super pretty but neither is global stuff I suppose yield parse(this) vs yield this.parse() sort of deal

@jonathanong
Copy link
Member Author

Ah yeah. It's easier to just do wrap(app) at this point. I'm all for removing app.context()

@tj
Copy link
Member

tj commented Nov 6, 2013

k sweet let's do that for now

@tj
Copy link
Member

tj commented Nov 8, 2013

consensus for now is to assume protos are nice enough to use without extending for now haha

@tj tj closed this as completed Nov 8, 2013
@jonathanong
Copy link
Member Author

ohhh you can't extend at all now. i still want to extend it. i just think modules should extend it from require('module')(app) instead of app.context(require('module')) or app.mixin(require('module')).

@tj
Copy link
Member

tj commented Nov 8, 2013

I think it's an anti-pattern, a tempting one, but definitely an anti-pattern, tough call but I'd rather leave it out completely for now

@tj
Copy link
Member

tj commented Nov 8, 2013

at least until everything else is well defined and finished, maybe after 0.1.0

@jonathanong
Copy link
Member Author

I think it's an anti pattern if users rely on it, but it's fine for extending koa. I would make it private. It would be annoying to do things like yield body(this)

@tj
Copy link
Member

tj commented Nov 8, 2013

that's annoying but it's also annoying to hunt down where these magical methods are coming from if you're unfamiliar with the app, but ugly indeed

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

No branches or pull requests

2 participants