I want to understand why the API is just the Hydra object. What is the reason for extending the Hydra object instead of having a separate object just for the common API?
Hydra.module.register('adslot', ['$api'], function (api) {
return {
init: function () {
api.hello.say();
}
};
});
This is very intuitive, however I still do not see why "api" has to be the Hydra object instead of being it's own object or object literal. Bus is a separate object (Hydra.bus), why not API (Hydra.api)?
Then we could extend Hydra.api instead of just Hydra, I think this is better separation. The API is separate from Hydra.
In function dependencyinjection, then it would read:
As it is now, with my newly added 'hello' API property, these are the properties on the Hydra object:
version
bus
errorHandler
setErrorHandler
module
setUnblockUI
setDebug
getDebug
extend
noConflict
addExtensionBeforeInit
getCopyModules
getCopyChannels
setNamespace
hello
This would be much cleaner with an "api" property and then all API calls extend that. e.g Hydra.api.hello.say().
There is no difference inside module because of dependency injection, but it makes the code much easier to read and understand if you want to contribute to Hydra.js
I want to understand why the API is just the Hydra object. What is the reason for extending the Hydra object instead of having a separate object just for the common API?
If I have this code:
Then in my module I could do this:
This is very intuitive, however I still do not see why "api" has to be the Hydra object instead of being it's own object or object literal. Bus is a separate object (Hydra.bus), why not API (Hydra.api)?
Then we could extend Hydra.api instead of just Hydra, I think this is better separation. The API is separate from Hydra.
In function dependencyinjection, then it would read:
As it is now, with my newly added 'hello' API property, these are the properties on the Hydra object:
This would be much cleaner with an "api" property and then all API calls extend that. e.g Hydra.api.hello.say().
There is no difference inside module because of dependency injection, but it makes the code much easier to read and understand if you want to contribute to Hydra.js