Closed garth closed 8 years ago
Awesome :-)
Main issue is that component can't be sure which module name was used to register
Another one: I can't see a difference between controller.services.moduleName.service()
and controller.modules.moduleName.services.service()
why to dublicate?
I think that controller.services.moduleName.service() is the important one. The other is only there as a way for the module to export it's services, but could be removed.
The primary goal was to be able to use module services from any action.
function someAction({ services: { moduleName } }) {
moduleName.service();
}
I may want to reuse a service twice, eg multiple db's, so the unique moduleName given at module setup is important.
To access the given name you can use a factory, but with a factory then you can just access the other properties of the module directly also, so the name is then less important.
import Component from './components';
{
init({ controller, name }) {
return {
Component: Component(controller.modules[name])
}
}
export default function (module) {
class ModuleComponent extends Component {
render() {
<Link signal={module.signals.clicked}>Send namespaced module signal</Link>
}
}
return ModuleComponent;
}
Companion to https://github.com/cerebral/cerebral/pull/149
enables the following: