firstandthird / domodule

Declarative DOM module
MIT License
6 stars 4 forks source link

Support for plugins #10

Open dawnerd opened 8 years ago

dawnerd commented 8 years ago

Proposing adding support for a function that will allow a plugin to add/override methods without having to use a long extends chain.

It could look something like this:

ajax.js

export default class Ajax {
  get(url, data) {
    //...
  }

  post(url, data) {
    //...
  }
}

app.js

import Ajax from './Plugins/ajax.js';
Domodule.registerPlugin(Ajax);

Not sure how we'd handle constructors though.

You think this would be helpful?

jgallen23 commented 8 years ago

FYI: https://facebook.github.io/react/blog/2016/07/13/mixins-considered-harmful.html

dawnerd commented 8 years ago

I've read that before and in the case of react and other huge frameworks it makes a lot of sense. For us though I think something more along the lines of http://matthijshollemans.com/2015/07/22/mixins-and-traits-in-swift-2/ makes more sense (implemented something like https://gist.github.com/lukescott/36453a75c39c539f5c7d at least until es7).

This would also allow us to break up the core class, something we can't really do right now.

jgallen23 commented 8 years ago

cool, I'll go through these