These method are mixed into
,
Lateralus
, and Lateralus.Component
.Lateralus.Component.View
- Source:
Members
(static) components :Object.<Lateralus.Component>
The subcomponents belonging to this object. Do not modify this property directly, it is managed by Lateralus.
- Source:
Type:
-
Object.<Lateralus.Component>
(static) 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 () {
// ...
}
});
- Default Value:
- undefined
- Source:
Type:
-
Object
|undefined
(static) 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) {
// ...
}
}
});
- Default Value:
- undefined
- Source:
Type:
-
Object
|undefined
(static) 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]
- Source:
Type:
-
Object
|undefined
Methods
addComponent(Component, viewOptionsopt, optionsopt) → {Lateralus.Component}
Add a subcomponent to a
or Lateralus
instance.Lateralus.Component
const App = Lateralus.beget(function () {
Lateralus.apply(this, arguments);
});
const app = new App(document.getElementById('app'));
const component = app.addComponent(Lateralus.Component);
const subcomponent = component.addComponent(Lateralus.Component);
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Component |
Lateralus.Component
|
A constructor, not an instance. |
|||||||||||||
viewOptions |
Object
|
<optional> |
The |
||||||||||||
options |
Object
|
<optional> |
Gets passed to the new
|
amplify(emitter, eventName)
Listen to an event-emitting Object and amplify one of its events across the
Lateralus
application. Useful for making plain Backbone Objects
(i.e., non-Lateralus Objects) communicate important information in a broader
way.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
emitter |
Backbone.Events
|
The object that |
eventName |
string
|
The event to amplify globally across the app. |
collect(key, …argsopt) → {Array.<any>}
Execute any
handlers that have
been set up in the app and return an array of the returned values.Lateralus.mixins.provide
Values that are undefined
are excluded from the returned Array.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string
|
The name of the |
|
args |
any
|
<optional> <repeatable> |
Any parameters to pass along to |
Returns:
- Type:
-
Array.<any>
collectOne(key, …argsopt) → {any}
Execute any
handlers that have been set
up in the app and return the first value.Lateralus.mixins.provide
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string
|
The name of the |
|
args |
any
|
<optional> <repeatable> |
Any parameters to pass along to |
Returns:
- Type:
-
any
emit(eventName, …argsopt)
Components should never communicate directly with one another in order to
maintain a loosely-coupled architecture. Instead, they should just
broadcast general messages with the Backbone.Events
API. emit
facilitates this loose
coupling by firing an event that bubbles throughout the app, depending on
what calls it:
- If this is called by
, this just triggers an event on thatLateralus
instance.Lateralus
- If this is called by a
, this triggers an event on thatLateralus.Component
as well as the centralLateralus.Component
instance.Lateralus
- If this is called by a
, this triggers an event on thatLateralus.Component.View
, theLateralus.Component.View
to which it belongs, and the centralLateralus.Component
instance.Lateralus
This method has the same method signature as
Backbone.Events.trigger
.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string
|
The name of the event. |
|
args |
any
|
<optional> <repeatable> |
Any arguments to pass along to the listeners. |
initCollection(Collection, modelsopt, optionsopt) → {Lateralus.Component.Collection}
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
Collection |
Lateralus.Component.Collection
|
A constructor, not an instance. |
|
models |
Array.<Lateralus.Model>
|
<optional> |
|
options |
Object
|
<optional> |
initModel(Model, attributesopt, optionsopt) → {Lateralus.Component.Model}
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
Model |
Lateralus.Component.Model
|
A constructor, not an instance. |
|
attributes |
Object
|
<optional> |
|
options |
Object
|
<optional> |
listenFor(event, callback)
Listen for an event that is triggered on the central Lateralus
instance and bind a function handler.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
string
|
The name of the event to listen for. |
callback |
function
|
The function handler to bind. |
mixin(mixin)
Merge the properties of another object into this object. If the mixin
configuration object has a method called initialize
, it is called in the
context of the object calling this function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
mixin |
Object
|
The object to mix in to this one. |