Put your global variables and functions in your app/alloy.js
:
Alloy.Globals.myModule = require("myModule");
Alloy.Globals.myFunction = function(e){
// your logic function
};
Question
I'm new to Appcelerator and Titianium Alloy, and I wandering how the global scope works in the controller Javascript files.
It is still best practice to attach all of your variables to a single global object within these files? In a lot of tutorials it seems that they are just declaring variables with quite common names right in the file with no closure of the scope.
La solution
Put your global variables and functions in your app/alloy.js
:
Alloy.Globals.myModule = require("myModule");
Alloy.Globals.myFunction = function(e){
// your logic function
};