Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column
width15px

Column

The presentation model (PM) approach is the recommended view layer architecture for Swiz.
The goal is to remove any logic from the view and let the PM handle the view logic.
The view gets the PM injected and binds data from it and delegates all interactions (events) to the PM.

Code Block
titleMyView.mxml
borderStylesolid

<?xml version="1.0" encoding="utf-8"?>
<s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
					  xmlns:mx="library://ns.adobe.com/flex/mx" currentState="{model.currentState}">
	<fx:Script>
		<![CDATA[
			import example.model.presentation.MyPresentationModel;
			[Bindable]
			[Inject]
			public var model:MyPresentationModel;
		]]>
	</fx:Script>

	<s:layout>
		<s:VerticalLayout />
	</s:layout>

	<s:states>
		<s:State name="state1default" />
		<s:State name="state2detail" />
	</s:states>

	<s:List labelField="{model.listLabelField}" dataProvider="{model.dataProvider}" change="model.changeListIndex(event.newIndex)" />

	<s:Label includeIn="detail" text="{model.selectedTitle}" />

	<s:Button includeIn="detail" label="Edit" click="model.edit()" />

</s:SkinnableContainer>


Having no logic in the view itself also means that you only have to unit test your PM.

Column
width15%