Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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.

MyView.mxml
<?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="default" />
		<s:State name="detail" />
	</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.

  • No labels