Skip to content

Core Events

Tom Taylor edited this page Nov 30, 2017 · 10 revisions

Due to the modular approach we've taken for the architecture of the client application, we make heavy use of the observer code design pattern, and use events to keep the various parts of the application updated.

Additionally, our chosen framework for structuring the client application (Backbone.js) has very good support for an event-driven approach.

Backbone built-in events

Backbone supports a wide variety of different events which we make use of extensively throughout the application. Please see the Backbone.js documentation for more information:

Adapt built-in events

In addition to the Backbone events, we've added many events which we use throughout the application, and can be listened to by any plugin code.

You can listen to system events using the following syntax: Origin.on(FUNCTION, CALLBACK_FUNCTION)

For example:

Origin.on('origin:initialize', function() {
  console.log('App is ready to go');
});

Core Events

See below for a list of core events, and what they signal.

Origin events

Event name What it signals Parameters passed to callback
origin:dataReady The app's data has been loaded, and is about to initialise
origin:initialize the app has initialised
origin:showLoading
origin:hideLoading
origin:sessionStarted
remove:views

Window events

We've also included some of the Window object's events for ease of use:

Event name What it signals Parameters passed to callback
key:down
window:resize
window:focus
window:blur

Misc events

Event name What it signals Parameters passed to callback
constants:loaded
l10n:loaded
location:change
router:MODULE:LOCATION1:LOCATION2:LOCATION3:LOCATION4
contentCollection:dataLoaded
VIEW:preRender
VIEW:postRender
Clone this wiki locally