Dependencies - ccmjs/ccm GitHub Wiki
There are 2 types of resource dependencies:
- dynamic (at run-time)
- semi-dynamic (at run-time, but only at start-up time)
So far, there is no static dependency management. All resource dependencies are managed at run-time.
Semi-dynamic dependencies should be preferred, because they are solved at start-up time in the init phase of the component life-cycle.
Dynamic Dependencies
const result = await ccm.start( "path/to/ccm.sub_component.js", individual_config );
Semi-dynamic Dependencies
There are two types of semi-dynamic dependencies:
Dependent components with multiple instances
Declare a component dependency inside the config of a master component as follows:
config: {
sub_component: [ "ccm.component", "path/to/ccm.sub_component.js" ]
...
}
// start sub component with individual config
start: async () => {
const instance = await this.sub_component.instance( individual_config );
const result = await instance.start();
}
Dependent single instance
Declare a instance dependency inside the config of a master component as follows:
config: {
sub_component: [ "ccm.instance", "path/to/ccm.sub_component.js", "individual config" ]
...
}
start: async () => {
const result = await this.sub_component.start();
}