Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: AsyncCommands - Proxy or Command handler parses/processes data?  (Read 6475 times)
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« on: October 21, 2008, 12:40:02 »

In a current Flex/AIR project I figured I'd try a different approach within PureMVC than what I'm used too. I've created commands that make remote service calls and contain event handlers for fault or result events. If an asynchronous command receives a JSON result, should that handler have the responsibility of parsing the JSON and setting the necessary properties of your data objects or should that be the responsibility of the proxy?

I've always had all this functionality in my proxies but with this different approach I'm curious how others might be handling this. Do your commands know a lot about the model? Do they pull an object from an ArrayCollection, update the properties on that object? Or do you have your proxy parse the data returned (JSON, XML, etc.) to update the model?

Thoughts?
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: October 21, 2008, 01:14:39 »

Like you, I've always kept this stuff in my Proxies. If I were to use Commands as Responders then I would likely still keep the parsing in the proxies and just have the Command either create a proxy on result and set a property with the raw response, or have it access an existing Proxy and make a call like MyProxy.parseResult(myJSONResponse). I like the former since if the return is a Fault() then no proxy gets created since there's no data to feed it. This is very similar to how Cairngorm in Flex uses Commands as Responders by implementing an IResponder interface.

My $0.02.
« Last Edit: October 21, 2008, 01:18:02 by jasonmac » Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #2 on: October 21, 2008, 01:39:50 »

@jasonmac

Thanks for the reply! Appreciate your 2 cents although I feel its worth much more. :)

I've always had my service calls in my proxies but sometimes can get a bit out of hand. I noticed rarely ever having any commands and I liked the approach of having it in a command. I decided on this project to give it a shot.

With this though I realized my proxies don't really do much at all. From there I wondered if best to do parsing in the command but the parsing and setting properties or so coupled. I'll go with your suggestion. I figure the parsing is so data related that is the proxies responsibility so best to do that there.
Logged
Pages: [1]
Print