bob.ns Namespace (bob.js JavaScript Framework)

 

bob.ns namespace defines functionality related to registering and extending JavaScript namespaces.

 

setNs - function

setNs(ns [, extension])

 

Registers new, or extends existing JavaScript namespace with given extension object's members.

 

Parameters:

ns - string defining namespace name. Use period (.) to separate nested namespace name parts (e.g. 'bob.collections.extensions').

extension - (optional) JavaScript object containing members (functions and fields) that will be copied under a newly created namespace. If this parameter is missing, empty namespace will be created.

 

Example:

bob.ns.setNs('myApp.myMethods', {
method1: function() {
 console.log('This is method 1');
 }
method2: function() {
 console.log('This is method 2');
 }
});
//call method1.
 myApp.myMethods.method1();
//call method2.
 myApp.myMethods.method2();

See Also

bob.js on CodePlex.

JavaScript namespaces via bob.js.

Last edited Oct 11, 2012 at 1:59 PM by ttutisani, version 2

Comments

No comments yet.