Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created June 12, 2012 04:07
Show Gist options
  • Save egomez99/2914859 to your computer and use it in GitHub Desktop.
Save egomez99/2914859 to your computer and use it in GitHub Desktop.
Non Stack overflow when circular referencing commonJS modules
var MyWindow = require('somewindow');
MyWindow().open();
exports.Info = function(text){
var UI = require('ui');
Ti.API.info(text);
}
module.exports = function(){
var UI = require('ui');
return UI.Win();
}
exports.View = function(){
var Log = require('log');
Log.Info('Hello World, this is a view');
return Ti.UI.createView();
}
exports.Win = function(){
var Log = require('log');
Log.Info('Hello World, this is a window');
return Ti.UI.createWindow();
}
//Do not try this!
//var Log = require('log');
//Log.Info('Hello World, this is a window - Outside the exports');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment