PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: pwhitfie on March 02, 2008, 03:53:28



Title: How to treat Flex StyleManager
Post by: pwhitfie on March 02, 2008, 03:53:28
Hi all,

I've been working on porting the Adobe AIR employee directory sample app to PureMVC as a learning exercise and I've come across a question that I'd like some input on.

The existing app has the following code in a LoadStyleSheetCommand:

:
var declEvent:IEventDispatcher = StyleManager.loadStyleDeclarations( fileName );
declEvent.addEventListener( StyleEvent.COMPLETE, onStyleLoad );
declEvent.addEventListener( StyleEvent.ERROR, onStyleLoadError );

If my understanding is correct, we shouldn't be using Flex events in a Command so here is my question:

do I treat the Flex StyleManager as a UI component and therefore create a StyleManagerMediator?

or is there a better way to handle this?

I'm inclined to come down on the side of the Mediator approach as this keeps all Flex event handling in the view.

Any suggestions?

Thanks,

Pete



Title: Re: How to treat Flex StyleManager
Post by: puremvc on March 02, 2008, 06:09:33
Since it communicates with the outside world, we would consider the StyleManager a Boundary object.

But it comminicates with the server to fetch the file.

It could be seen as communicating with the user, but really it just informs the view about how to look in the same way that data fron a remote database, once fetched, informs the view about what to display.

So from that perspective, the natural place for this code would be in a Proxy.

It is common to create a service in a Proxy and set listeners on it for its result and fault events in the same way you described in your code.

Event handling happens at both boundries of the app, not just in the View.

-=Cliff>   


Title: Re: How to treat Flex StyleManager
Post by: pwhitfie on March 02, 2008, 03:14:34
Thanks Cliff!

I had thought about this as well but confused myself by thinking that Proxies were specifically for managing data. Having gone back to look at the IProxy interface I now realise that the interface does not impose any limits.

Thanks for your help.

Cheers,

Pete