FwdRatesPM.as

The only stipulation here, is that the model extends EventDispatcher, and that it expects to handle the [CommandResult]. It does not care where this has come from – either the mockAction or the real thing.


package
{
	import FwdRatesEvent;
	import flash.events.EventDispatcher;
	import mx.collections.ArrayCollection;
	import mx.logging.ILogger;
	import mx.logging.Log;
	import FxForwardDisplay;
	import spark.events.IndexChangeEvent;

	[Event( name="fwdRatesEvent", type="FwdRatesEvent")]
	[ManagedEvents("fwdRatesEvent")]

	public class FwdRatesPM extends EventDispatcher
	{
		private var log:ILogger = Log.getLogger("FwdRatesPM");

		[Bindable]
		public var fwdRates:ArrayCollection = new ArrayCollection();

		public function FwdRatesPM()
		{
		}

		public function getFwdFXRates() : void
		{
			dispatchEvent(new FwdRatesEvent());
		}

		[CommandResult]
		public function onFXFwdRatesResult(fwdRateCollection:ArrayCollection, event:FwdRatesEvent) : void
		{
			log.info("received FwdRates");
			...

		}

		private function addOrUpdateRates(r:FxForwardDisplay) : void
		{
                  ..
		}
	}
}