Constructor
new Component(lateralus, options, viewOptions, opt_parentComponentopt)
The constructor for this method should not be called directly. Instead, use
the
mixin method:Lateralus.mixins#addComponent
const App = Lateralus.beget(function () {
Lateralus.apply(this, arguments);
});
const app = new App(document.getElementById('app'));
const component = app.addComponent(Lateralus.Component);
console.log(component instanceof Lateralus.Component); // true
- Mixes In:
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lateralus |
Lateralus
|
||||||||||||||
options |
Object
|
Values to attach to this
|
|||||||||||||
viewOptions |
Object
|
The |
|||||||||||||
opt_parentComponent |
Lateralus.Component
|
<optional> |
The parent component of this component, if any. |
Classes
Members
components :Object.<Lateralus.Component>
The subcomponents belonging to this object. Do not modify this property directly, it is managed by Lateralus.
- Mixes In:
- Source:
Type:
-
Object.<Lateralus.Component>
initialize :function|undefined
A method to be called when this
has been set
up.Lateralus.Component
- Default Value:
- undefined
- Source:
Type:
-
function
|undefined
lateralusEvents :Object|undefined
A map of functions or string references to functions that will
handle events dispatched to the
central
instance.Lateralus
const ExtendedComponent = Lateralus.Component.extend({
name: 'extended',
lateralusEvents: {
anotherComponentChanged: 'onAnotherComponentChanged',
anotherComponentDestroyed: function () {
// ...
}
},
onAnotherComponentChanged: function () {
// ...
}
});
- Mixes In:
- Default Value:
- undefined
- Source:
Type:
-
Object
|undefined
modelEvents :Object|undefined
A map of functions or string references to functions that will
handle events emitted by
this.model
.
const ExtendedComponent = Lateralus.View.extend({
modelEvents: {
changed:someProperty: function (model, someProperty) {
// ...
}
}
});
- Mixes In:
- Default Value:
- undefined
- Source:
Type:
-
Object
|undefined
parentComponent :Lateralus.Component|undefined
If this is a subcomponent of another
, this
property is a reference to the parent Lateralus.Component
.Lateralus.Component
- Default Value:
- undefined
- Source:
Type:
-
Lateralus.Component
|undefined
provide :Object|undefined
A map of functions that will handle
calls. Each of the functions attached to this Object should return a
value. These functions must be completely synchronous.Lateralus.mixins#collect
const App = Lateralus.beget(function () {
Lateralus.apply(this, arguments);
});
_.extend(App.prototype, {
provide: {
demoData: function () {
return 1;
}
}
});
const app = new App();
const ComponentSubclass = Lateralus.Component.extend({
name: 'provider',
provide: {
demoData: function () {
return 2;
}
}
});
app.addComponent(ComponentSubclass);
console.log(app.collect('demoData')); // [1, 2]
- Mixes In:
- Source:
Type:
-
Object
|undefined
view :Lateralus.Component.View|undefined
If
is defined, this is an instance of
that constructor.Lateralus.Component.View
- Default Value:
- undefined
- Source:
Type:
-
Lateralus.Component.View
|undefined
View :Lateralus.Component.View|undefined
The
constructor to use, if any. If
this Lateralus.Component.View
is intended to render to the DOM,
Lateralus.Component
View
should be defined on the prototype
before instantiating:
const ExtendedComponent = Lateralus.Component.extend({
name: 'extended',
View: Lateralus.Component.View,
template: '<div></div>'
});
- Default Value:
- undefined
- Source:
Type:
-
Lateralus.Component.View
|undefined
Methods
dispose()
Remove this
from memory. Also remove any
nested components added by Lateralus.Component
.Lateralus.mixins#addComponent
- Source:
extend(protoProps)
Create a
subclass.Lateralus.Component
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
protoProps |
Object
|
|
toJSON() → {Object}
Meant to be overridden by subclasses.
- Source:
Returns:
- Type:
-
Object
toString() → {string}
- Source:
Returns:
- Type:
-
string
The name of this Component. This is used internally by Lateralus.