presentation model pattern with flex and swiz framework
TRANSCRIPT
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model pattern with Flex and Swiz FrameworkPiotr Walczyszyn | Platform Evangelist
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
About me
2
Piotr WalczyszynPlatform Evangelist
http://riaspace.com
http://twitter.com/
pwalczyszyn
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3
Presentation Model
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model
4
Presentation Model
View
State & LogicProvides Model dataDecoupled from View
Observes Model dataUpdates Model dataCoupled with PM
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model: Main.mxml
5
Main.mxml
<swiz:Swiz />
MainPMcurrentState:String<views:MainView />
model +1
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model: MainView.mxml
6
MainView.mxmlcurrentState=“{model.currentState}”
UsersListPMusers:ArrayCollecti
on
<views:UsersListView includeIn=“USERS_LIST_STATE” />
model +1
AddUserPMuser:User
createUser():void
<views:AddUserView includeIn=“ADD_USER_STATE” />
model +1
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model: UsersListView.mxml
7
UsersListView.mxml
<s:List dataProvider=“{model.users}” />
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Presentation Model: AddUserView.mxml
8
AddUserView.mxml
<s:TextInput text=“@{model.user.name}” />
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9
Swiz
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Swiz Intro
Framework for Flex
Lightweight & flexible
Doesn’t enforce any design patterns, project layout or inheritance
Decoupled from your application code
10
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Swiz Features
Inversion of Control / Dependency Injection
[Inject]
Event handing and mediation
[Dispatcher], [Mediate]
Handling bean life cycle
[PostConstruct], [PreDestroy]
Simplifies remote service calls
ServiceHelper, MockDelegateHelper
Chaining API
EventChain, CommandChain
Custom Metadata Processors
[URLMapping], [MediateSignal], [Resource], [Logger], [Bind]
11
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Swiz Links
http://swizframework.org/
http://swizframework.jira.com/wiki/display/SWIZ/Home
12
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 13
Demo
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14
Full Class Diagram
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.