tags:

views:

40

answers:

1

Is there any way to avoid writing data to the singleton ModelLocator in Cairngorm?

In my current mxml files, I have something like

new LoginEvent(LoginEvent.GET_LOGIN_EVENT).dispatch();

And this fires off the event and command. In the command, we have something like:

public function result(data:Object):void
{       
  var returnedData:Array = data.result as Array
  model.login = returnedData;
}

Instead, I'd like to actually return the command result directly to the view. So, in the mxml file I have:

var loginResult:Array = new LoginEvent(LoginEvent.GET_LOGIN_EVENT).dispatch();

Which would necessiate the command changing to:

public function result(data:Object):array
{       
  var returnedData:Array = data.result as Array
  return returnedData;
}

Is this even possible?

A: 

You can use something like ViewNotifications. The idea is to add IResponders to events, so they can be used like callbacks to send data back to the view.

fgb
Yup, I'd figurered this out already - just return the command's result via a callback to the view.
JonoB