Skip to content

4. Integration with PureMVC

Eric-Paul Lecluse edited this page May 17, 2011 · 3 revisions

The core of the Navigator library is and will be completely dependency-free, but there are packages with helper classes for integrating into existing frameworks, like the PureMVC framework. Lately I've been working more with another framework. Be sure to also checkout the example for RobotLegs as well.

By providing standard PureMVC mediators and a proxy wrapper of the Navigator called NavigationProxy, getting up to speed is done in seconds. Have your mediators extend TransitionMediator, and use the XML based state map to easily add dozens of mediators to the NavigationProxy. Especially by using the <auto /> behavior, you can add an instance for all the interfaces it implements with just one line of XML. Here's an example of how to setup a fairly simple state machine in PureMVC:

var np : NavigationProxy = NavigationProxy(facade.retrieveProxy(NavigationProxy.NAME));
		 
var map : XML = <map>
	<state path={States.OUTSIDE}>
		<auto>{OutsideMediator.NAME}</auto>
	</state>
	<state path={States.INSIDE}>
		<auto>{BackgroundMediator.NAME}</auto>
		<auto>{ForegroundMediator.NAME}</auto>
	</state>
	<state path={States.HOME}>
		<show>{PageHomeMediator.NAME}</show>
	</state>
	<state path={States.VODAFONE}>
		<show>{PageVodafoneMediator.NAME}</show>
	</state>
	<state path={States.LOCATION}>
		<show>{PageLocationMediator.NAME}</show>
	</state>
	<state path={States.PROGRAM}>
		<show>{PageProgramMediator.NAME}</show>
	</state>
	<state path={States.REGISTRATION_THANK_YOU}>
		<show>{PageThankYouMediator.NAME}</show>
	</state>
	<state path={States.CONTACT}>
		<show>{PageContactMediator.NAME}</show>
	</state>
	<state path={States.DISCLAIMER}>
		<show>{PageDisclaimerMediator.NAME}</show>
	</state>
</map>;

np.parseMediatorStateMap(map);