Quick Way to work with Models and Alloy in Appcelerator Titanium
For those who have taken the dive into Alloy from Appcelerator, understanding how models work can definitely simplify your overall application architecture and then you can also leverage the functionality of Backbonejs Models.
This approach minimizes the number of files you need to create and creates a persistence mechanism using the Titanium Properties framework.
Salesforce Miami User Group Event - 1st Quarter 2024
Quick Way to work with Models and Alloy in Appcelerator Titanium
1. Quick
Method
for
working
with
Models
in
Alloy
Aaron
K.
Saunders
CEO
Clearly
Innova?ve
Inc
June
2013
2. About
Alloy
Alloy
is
a
new
applica?on
framework
by
Appcelerator
for
Titanium.
It
provides
a
MVC
framework
for
developers
that
are
building
Titanium
apps.
hJp://docs.appcelerator.com/?tanium/latest/#!/guide/Alloy_Framework
3. Appcelerator
Alloy
&
Models
• What
is
Appcelerator
Alloy,
See
link
below
for
slide
deck
with
overview.
– hJp://www.slideshare.net/aaronksaunders/
modev-‐east2012
• Who
is
This
For
– This
deck
assumes
you
have
a
basic
understanding
of
Alloy
and
Backbone
Models
– Have
created
Alloy
Models
in
your
app
and
are
looking
for
an
easier
integra?on
4. Quick
Way
to
Integrate
Models
When
I
am
working
and
want
to
get
something
going
quickly
with
models,
I
hate
to
create
the
addi?onal
files
to
just
get
access
to
a
model
so
I
use
this
simple
hack
below.
This
allows
me
to
save
my
models
to
an
Appcelerator
Titanium
Property
5. Crea?ng
the
Module
Object
We
need
to
also
set
the
collec?on_name
property
on
the
model
so
Alloy
and
the
proper?es
sync
module
knows
how
to
persist
the
object
6. Cleaning
Up
the
Model
Object(s)
To
clean
up
the
objects,
we
will
extend
the
Collec?on
object
to
have
a
cleanup
method.
This
method
will
use
the
collec?on_name
to
find
the
models
that
were
saved
as
Appcelerator
Titanium
Proper?es
7. Crea?ng
a
Collec?on
Object
and
Cleaning
Up
Here
we
create
a
UserCollec?on
from
the
Collec?on
Object
we
extended
on
the
previous
slide.
We
take
this
approach
so
that
all
Collec?ons
created
will
now
be
able
to
call
the
cleanup
func?on
to
purge
any
associated
models.
8. The
Source
Code
• Gists
– hJps://gist.github.com/aaronksaunders/
75a3e23cda8a830d31fc
• Blog
Post
– hJp://www.clearlyinnova?ve.com/blog/post/
34758524608/quick-‐way-‐to-‐work-‐with-‐models-‐and-‐
alloy-‐in-‐appcelerator-‐?tanium
• Alloy
Proper?es
Async
Adapter
– hJps://github.com/appcelerator/alloy/blob/master/
Alloy/lib/alloy/sync/proper?es.js
9. Aaron
K
Saunders
Twi$er:
@aaronksaunders
blog:
hJp://blog.clearlyinnova?ve.com
Facebook:
hJps://www.facebook.com/ClearlyInnova?veInc
Github
:
hJps://github.com/aaronksaunders/
SlideShare:
hJp://www.slideshare.net/aaronksaunders/
1706
R
Street,
NW
Washington,
DC
20009
www.clearlyinnova?ve.com