Presentation Model pattern with Flex and Swiz framework

15
© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Presentation Model pattern with Flex and Swiz Framework Piotr Walczyszyn | Platform Evangelist

Transcript of Presentation Model pattern with Flex and Swiz framework

Page 1: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Presentation Model pattern with Flex and Swiz FrameworkPiotr Walczyszyn | Platform Evangelist

Page 2: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

About me

2

Piotr WalczyszynPlatform Evangelist

http://riaspace.com

http://twitter.com/

pwalczyszyn

Page 3: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3

Presentation Model

Page 4: Presentation Model pattern with Flex and Swiz framework

© 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

Page 5: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Presentation Model: Main.mxml

5

Main.mxml

<swiz:Swiz />

MainPMcurrentState:String<views:MainView />

model +1

Page 6: Presentation Model pattern with Flex and Swiz framework

© 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

Page 7: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Presentation Model: UsersListView.mxml

7

UsersListView.mxml

<s:List dataProvider=“{model.users}” />

Page 8: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Presentation Model: AddUserView.mxml

8

AddUserView.mxml

<s:TextInput text=“@{model.user.name}” />

Page 9: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9

Swiz

Page 10: Presentation Model pattern with Flex and Swiz framework

© 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

Page 11: Presentation Model pattern with Flex and Swiz framework

© 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

Page 12: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Swiz Links

http://swizframework.org/

http://swizframework.jira.com/wiki/display/SWIZ/Home

12

Page 13: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 13

Demo

Page 14: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14

Full Class Diagram

Page 15: Presentation Model pattern with Flex and Swiz framework

© 2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.