Adobe Flex Cairngorm - avoid singleton
-
24-10-2019 - |
سؤال
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?
المحلول
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.
لا تنتمي إلى StackOverflow