jgallen23 / fidel

A basic javascript controller
MIT License
36 stars 4 forks source link

fidel plugin system #9

Open jgallen23 opened 10 years ago

jgallen23 commented 10 years ago

Right now we have events for FidelPostInit, but I think there's probably a better way to extend fidel. If we build correctly, we can split the features up into their own plugins

jgallen23 commented 10 years ago

Idea 1 (data-elements example)

fidel.plugin({
  defaults: {
  },
  init: function() {
    this.getDataElements();
  },
  getDataElements: function() {
     this.find('[data-element]').forEach(function(el) {
         self.els[name] = el;
     });
  }
});

So fidel would just expose a bare bones amount of functionality, but it could be easily extended. We would have built in plugins for data elements, events, delegate actions, etc. And then we could build plugins for integration with bind-to, etc.

jgallen23 commented 10 years ago

@Belelros @dawnerd let me know what you think

Antonio-Laguna commented 10 years ago

I think this is great but, on the other hand I think we would end up bloating the library a little bit just to achieve this and most of the stuff will always be included.

jgallen23 commented 10 years ago

I'm hoping it wouldn't add too much bloat. Maybe we don't allow options and defaults for plugins, they are just an init, destroy and custom methods.

I don't think everything will be built in. Here are some ideas for plugins that won't be built in bind-to, template rendering, form validation, hash routing.

More than anything I think it cleans up the code and gives us the flexibility to build on Fidel without making the core lib too big.

Antonio-Laguna commented 10 years ago

Oh, I see. Now it has more sense and I think it would be really great having the ability to hand-pick some pieces of functionality here and there.

Antonio-Laguna commented 10 years ago

How this should work?

I imagine plugins being stored as they're declared internally, then on the module definition, we could have an array of plugins to use and we would extend the module with the given plugins.

Do you have anything else in mind?

jgallen23 commented 10 years ago

Yep. Sounds right. Take a stab at what you are thinking in a branch