Namespaces in Lava allow are used to separate other objects, logic and even whole applications. The following example creates two objects with different namespaces. The first object is created in the global namespace because we do not specify a namespace for it. The second object is contained within the namespace Controllers.

var Sample = Lava.Object({
    value: 0

var PersonController = Lava.Object({
    name: null
}, 'Controllers');

Another example, which would provide better structure for a single page app:

var App = {};
App.Contacts = {};
App.Orders = {}

App.Contacts.Person = Lava.Object({
    first: 'John',
    last: 'Doe',
    age: 44
}, 'App.Contacts');

App.Orders.Order = Lava.Object({
    company: 'Some Company'
}, 'App.Orders');

Last edited Dec 11, 2012 at 5:24 PM by tjscience, version 1


No comments yet.