Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Appcelerator Ti.include & require

I've started looking into Appcelerator 1.8.0 few days and back and i'm a little confused with Ti.include and require. As i understand, Ti.include is used to include content of a js file in another file, and require is used to get the public api exposed using exports. What i'm not able to understand is if require-export can be used to get hold of public API's do you really need include? Basically i'm trying to understand different between include and require?

like image 289
prashant Avatar asked Feb 06 '12 14:02

prashant


People also ask

What is Appcelerator Titanium framework?

September 2022) Titanium SDK is an open-source framework that allows the creation of native mobile apps on platforms including iOS, Android and Windows UWP from a single JavaScript codebase, developed by Appcelerator.

Is Appcelerator Titanium free?

You can get started with Appcelerator for development purposes for free!

What company developed titanium language?

Titanium is a product by a company called Appcelerator that allows you to build mobile apps in JavaScript and compile it out to native apps for iOS, Android, and BlackBerry.

What is titanium studio?

Titanium Studio is an all inclusive powerful Eclipse-based IDE, that simplifies the mobile development process. Use Titanium Studio to rapidly build, test, package and publish mobile, desktop and web applications.


1 Answers

Ti.require uses the CommonJS specification. Although files accessed via Ti.require have access to the Ti namespace, they do not have access to the Global namespace - any variables or functions you have declared in the main program. Ti.include files do have access to the global space and can modify or add to it. Ti.require is preferred, but not always practical. See https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium for information on the Ti.require function and https://wiki.appcelerator.org/display/guides/Mobile+Best+Practices for more best practices.

like image 90
Jeff Bonnes Avatar answered Oct 07 '22 01:10

Jeff Bonnes