americano
americano copied to clipboard
Changing plugins integration
In order to make the use of plugins more clear, I propose the following:
- plugins are features added to the americano instance (americano extends americano-plugin)
- we keep the "configure" method of cozy's plugin as the hook so plugins can run code when they are initialized (maybe we can rename configure to initialize).
This is already coded but there is one remaining point I'd like to discuss (well, others are open to discussion too).
Should we access the plugin properties and methods like this:
americano = require "americano"
americano.pluginProperty # eg: americano.getModel 'modelName'
Or like this:
americano = require "americano"
americano.pluginName.pluginProperty # eg: americano.cozy.getModel 'modelName'
I see pros and cons for both solutions:
- better integration and shorter calls for the first solution
- the "namespaced" approach of the second removes the risk of plugins using the same name for a property
An other solution could be to have both (with overrides in the first case) but I don't like it much... Also, the "namespacification" could be done in the plugin by naming the property pluginNameProperty. Eg: cozyGetModel but i don't like that at all.
What do you think ?
After-lunch thoughts: the namespacing of plugin's properties can only be a problem if someone uses a lot of them. Since Americano is not designed for expansive applications the probability it occurs is very low. Also the syntax is much better in the first solution.
I prefer the first one because:
- Actually there are not much plugins.
- it's shorter
- as you wrote, americano is meant to be used for lightweight applications that doesn't use a lot of plugins.
Let's do this then!