Titanium Appcelerator Quickie: Global Variables, Scopes & Events - Clearly Innovative | Web and Mobile DevelopmentClearly Innovative | Web and Mobile Development

Was doing my usual perusal of the Q&A Fourms of Appcelerator and saw a question that is asked may times in many different ways, and is critical to building well designed Titanium Mobile Applications. The question of course was about global variables.

Now first off, in training and in the documentation they say dont pollute the global namespace/scope.

They also strongly recommend using event based programming where you can pass JSON serializable data to event listeners

So in order to be a good soldier I will follow both of those recommendations using a simple example I found on the forums.

These two approaches are covered with complete examples in the Appcelerator Wiki and also in the certification training classe examples.

app.js

cart.js