Application
Collux application
app.createComponent(name, namespace:, metadata = {}) : Component
Create a component in application, and add this component to the application
Arguments
Arguement | Type | Description |
---|---|---|
name | String | the component name |
namespace | String | optional, the namespace, |
metadata | Object | optional, metadata object |
Create a 'view' component
const component = app.createComponent('view', 'com.collux.example', {
author: 'John'
})
app.addComponent(component) : void
Add a component to the application
Arguments
Arguement | Type | Description |
---|---|---|
component | Component | the component object |
app.hasComponent(name) : boolean
Check if the application has a component with the specific name
Arguments
Arguement | Type | Description |
---|---|---|
name | String | the name of the component |
Return
Type | Description |
---|---|
boolean | true, if has a component with specific name, otherwise false |
Check if the application has a component named 'store'
if (app.hasComponent('store')) {
console.log('has store component');
}
app.getComponentByName(name) : Component
Get the component by name
Arguments
Arguement | Type | Description |
---|---|---|
name | String | the name of the component |
Return
Type | Description |
---|---|
Compnent | the component object, otherwise, null |
get the component named 'store'
if (app.hasComponent('store')) {
let component = app.getComponentByName('store');
}