Model

Lateralus.Component. Model

new Model()

This class builds on the ideas and APIs of Backbone.Model.

Source:

Extends

  • Backbone.Model

Members

(readonly) component :Lateralus.Component

A reference to the Lateralus.Component to which this Lateralus.Component.Model belongs.

Properties:
Name Type Description
component
Source:
Type:

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:

(readonly) lateralus :Lateralus

A reference to the central Lateralus instance.

Source:
Type:

lateralusEvents :Object|undefined

A map of functions or string references to functions that will handle events dispatched to the central Lateralus instance.

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 Lateralus.mixins#collect calls. Each of the functions attached to this Object should return a value. These functions must be completely synchronous.

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

destroy(optionsopt)

Lateralus-compatible override for Backbone.Model#destroy.

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

This object is also passed to Backbone.Model.#destroy.

Name Type Attributes Description
dispose boolean <optional>

If true, call Lateralus.Component.Model/dispose:method after destroy operations are complete.

dispose()

Remove this Lateralus.Component.Model from memory. Also remove this Lateralus.Component.Model from the Lateralus.Component.Collection to which it belongs, if any.

Source:

toString() → {string}

Source:
Returns:
Type:
string

The name of this Model. This is used internally by Lateralus.