Core/Context

Core/Context

# new Core/Context()

The Context object is a state variable to hold the current application state. It extends Backbone.Model.

The context contains various states of the current View or Layout -- this includes the current model and collection, as well as the current module focused and also possibly the url hash that was matched.

Instantiate a context.

const Context = require('./context');
let myContext = new Context();

Creating a child context or retrieving an existing one.

Assuming myContext is a context instance.

let childContext = myContext.getChildContext({cid: <contextId>});

If does not match any child context, a new child context will be created.

Retrieving Data from the Context

A context is a Backbone Model, so its data is stored in the attributes:

var module = myContext.get('module'); // module = "Contacts"