Fokke Zandbergen
app imagineer
im·ag·i·neer “to both
imagine and create
something that is new”
ALLOY
28 januari 2012
Where’s alloy?
JavaScript
Native
Titanium
Alloy
“An alloy is a mixture or metallic solid
solution composed of two or more
elements”
“Alloys usually have different properties
from those of the component elements.”
What’s an alloy?
What’s in Alloy?
TSS
XML
Views
+
=
Libs
Widgets
JS definition
=
Models Controllers
Alloy.CFGconfig.json
How does Alloy work?
Views
Libs
Widgets
JS definition
=
Models Controllers
Alloy.CFGconfig.json
How does Alloy work?
Libs
Widgets
JS definition
=
Models ControllersCommonJS
Alloy.CFGconfig.json
How does Alloy work?
Libs
Widgets
JS definition
=
Models ControllersCommonJS
Alloy.CFG
How does Alloy work?
Collections
syncs
Stores
Libs
Widgets
Models ControllersCommonJS
Alloy.CFG
How does Alloy work?
optimization
Collections
syncs
Stores
Libs
Widgets
Models ControllersCommonJS
Alloy.CFG
How does Alloy work?
Alloy Views · Markup
• XML elements corresponds to Ti.UI objects
• Require other views and widgets
• id for access from controller
• platform and formFactor conditions
• platform specific folders
• bind events to controller methods
• bind markup to models via generated controller code
DEMO
Alloy Controllers
• $.someID to access view elements
• exports.baseController to inherit a parent controller
• platform (OS_) and environment (ENV_) constants
• Passing arguments: var args = arguments[0] || {};
• Alloy.Globals namespace
• Require libraries from ‘lib’ folder
DEMO
Alloy Models
• Abstracted BackboneJS, but still a must-read
• “Collections keep models in memory & synced to a store”
• Database > Connection > Result > Row
• Easily extend BackboneJS classes
• SQL, properties and localStorage sync adapters
• Migrations
• Model-View binding
DEMO
Alloy Views · Styles
• CSS like JSON style
• #ID over .class over element
• Titanium constants like Ti.UI.TEXT_ALIGNMENT_LEFT
• Alloy.Globals and Alloy.CFG for expressions etc.
• platform and formFactor conditions
• platform specific folders
DEMO
Alloy Views · Themes
• Overwrite assets
• Overrule styles
• Global app.tss
• platform and density specific (asset) folders
• config.json environment/platform dependent selection
DEMO
Alloy Widgets
• Self-contained Alloy components almost like mini-apps
• controllers, views, styles, assets, libs
• models and theming coming
• Require like views or use <Widget>
• Use widgets in widgets
• Marketplace and NPM-like distribution coming
DEMO
Alloy Optimization
• From app to Resources folder
• Platform specific folders, conditional styles, conditional JS
unused libraries and builtins all stripped out!
• UglifyJS for optimal speed and compactness
• Build configuration file for pre and post compile tasks
DEMO
How to get started with Alloy?
• Get Titanium Studio 3.x from www.appcelerator.com
• Follow me @FokkeZB or fokkezb.nl for upcoming:
• Slides
• Code shown today
• Alloy Quick Start and links to various resources
Q&A
Fokke Zandbergen
app imagineer
www.fokkezb.nl
mail@fokkezb.nl
@fokkezb

Alloy