Defining an app namespace

Using namespaces is important in Titanium app development, as it helps organize your code while not polluting the global namespace. The practice of creating variables and methods without being associated with a namespace or other scoping condition is called polluting the global namespace . Since these functions and objects are scoped globally, they will not be eligible for collection until the global namespace loses scope during application shutdown. This can often result in memory leaks or other unwanted side effects.

How to do it...

The following example shows how to create a namespace for our app in our app.js called my with three subnamespaces called ui, tools, and controllers.

var my = {ui:{},tools:{},controllers:{}}

As we build our recipes, we will continue to add functionality to the preceding namespaces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.144.214