new Model()
This class builds on the ideas and APIs of
Backbone.Model
. The constructor for
this class should not be called by application code, it is used by the
constructor.Lateralus
- Source:
Extends
- Backbone.Model
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>
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
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
Methods
onChange()
For every key that is changed on this model, a corresponding change:
event
is
ed. For example, Lateralus.mixins#emit
set
ting the "foo"
attribute will Lateralus.mixins#emit
"change:foo"
and provide
the changed value.
- Source:
toString() → {string}
- Source:
Returns:
- Type:
-
string
The name of this Model. This is used internally by Lateralus.