Router

Lateralus. Router

new Router()

This class builds on the ideas and APIs of Backbone.Router. The constructor for this class should not be called by application code. Instead, use Lateralus#initRouter.

Source:

Extends

  • Backbone.Router

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:

(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

toString() → {string}

Source:
Returns:
Type:
string

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