Alloy is a new application framework by Appcelerator for Titanium. It provides a nice MVC framework for developers that are building Titanium apps.
See details at http://www.github.com/appcelerator/alloy
Installing Alloy
- Download or update to version 2.1.2 or greater of Titanium Studio from http://preview.appcelerator.com
- Install the Alloy plugin from the "beta" stream of http://preview.appcelerator.com
Creating an Alloy Project
- Select File > New > Titanium Mobile Project
- Select the "Alloy" entry in the first screen.
- Continue the rest of the way through the wizard
Creating a new Controller
Controllers and views describe the logic and presentation of your application's information. Creating a controller creates control, style and view files for you to edit.
- Right-click on a your project in App or Project Explorer
- Select New > Alloy Controller
- Enter the name of the controller. It will warn you if a duplicate exists.
- Click OK
- /app/controllers/name.js, /app/styles/name.tss, and /app/styles/name.xml are created.
Creating a new Model
Models describe data about a specific item.
- Right-click on a your project in App or Project Explorer
- Select New > Alloy Model
- Enter the name of the model. It will warn you if a duplicate exists.
- Select the type of storage.
- For SQL, select enter the names of the items in the model and the corresponding type.
- Click OK
- /app/models/modelName.js and /app/models/modelName.json are created. It will also create a migration under /app/migrations/.
Creating a new Migration
Migrations allow your database to be migrated from one version to another.
- Right-click on a your project in App or Project Explorer.
- Select New > Alloy Model
- Enter the name of the migration. It will warn you if a duplicate exists.
- Click OK
- /app/migration/migrationName.js is created.
Creating a new Widget
Widgets are encapsulated bits of functionality that can be reused across your application.
- Right-click on a your project in App or Project Explorer.
- Select New > Alloy Widget
- Enter the name of the widget. It will warn you if a duplicate exists.
- Click OK
- /app/widgets/WidgetName is created as a folder structure with widget information.
Running your application
- In Project Explorer, click the Run button
- The application launches.
Debugging
Debugging is in-the-works, so you'll need to do a few workarounds at the moment.
- Show the Resources folder
- Project/App Explorer View Menu (small little triangle)
- Customize View...
- Uncheck Titanium Resource Folders
- Navigate to Resources/alloy/controllers
- Inside you’ll find the controller object
- Set breakpoints and eval variables
- It's obfuscated, so not for the faint of heart
Updating Alloy
If alloy is out of date, you can update it on the command line. Use:
Code Block |
---|
sudo npm update alloy -g |