Creating windows and its views - what approach?

You must Login before you can answer or comment on any questions.

Before the commonJS approach I've always created windows like this

var win = Titanium.UI.createWindow({      
            url: 'win1.js',
 
});
After seeing the community app example with the adoption of commonJS, it seems that they no longer use the url prorperty to point the the JS file with the window instructions.

Instead the method this community app uses is to create views using commonJS exports, then just add the view to the window, without using the url property.

Is this way the ideal way of creating windows?

— asked 1 year ago by Eric Lee
0 Comments

1 Answer

One of the main reasons for not using the url method of launching windows is that when you do so, you create a new execution context for the new window. The Appcelerator team suggest that this is not the best way to code your apps. The commonJS approach is more about writing code that is component based and encapsulated and re-usable. the framework supports this approach by only actually loading a commmonJS module once and can lead to performance benefits.

Your Answer

Think you can help? Login to answer this question!