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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Re: Conditional AsyncCommands on: November 08, 2011, 09:08:00
Great !

Yeah that's actually a good point, I thought that if you pass a reference to an object's function you keep it in the reference count, but as I understand from what you say it isn't the case with server calls.

Looking forward for the new version.
Thanks!
Shai
2  Announcements and General Discussion / Architecture / Re: Conditional AsyncCommands on: November 07, 2011, 08:53:14
Sure thing!

Thanks for this platform and for taking the time to review my modifications.

Best Regards,
Shai Reznik
3  Announcements and General Discussion / Architecture / Re: Conditional AsyncCommands on: November 05, 2011, 11:09:11
Absolutely !
Please let me know if I'm missing something.

I'm posting only the modifications:


Modifications to MacroAsyncCommand -

:


                private function nextCommand ( shouldContinue:Boolean = true ) : void
{
if ( shouldContinue && subCommands.length > 0)
{
var commandClassRef:Class = subCommands.shift();
var commandInstance:Object = new commandClassRef();
var isAsync:Boolean = commandInstance is IAsyncCommand;

if (isAsync) IAsyncCommand( commandInstance ).setOnComplete( nextCommand );

ICommand( commandInstance ).initializeNotifier( multitonKey );
ICommand( commandInstance ).execute( note );
if (!isAsync) nextCommand();
}
else
{
if( onComplete != null ){
onComplete( shouldContinue );
}
subCommands = [];
note = null;
onComplete = null;
}
}



Modifications to AsyncCommand -

:

                 /**
* Notify the parent <code>AsyncMacroCommand</code> that this command is complete and it can continue the macro.
*/
protected function commandComplete () : void
{
onComplete( true );
}

/**
* Notify the parent <code>AsyncMacroCommand</code> that this command is complete but it should stop the macro.
*/
protected function stopMacro () : void
{
onComplete( false );
}



Thanks again,
Shai Reznik
4  Announcements and General Discussion / Architecture / Re: Can AsyncCommands act as responders? on: November 04, 2011, 05:50:04
I see what you mean now, so the objective is to not letting the proxy invoke specific methods of the controller tier.

Thank you for your patience and for teaching me (and the rest of the readers) a thing or two :)
5  Announcements and General Discussion / Architecture / Conditional AsyncCommands on: November 04, 2011, 08:21:49
Hey everyone !

When I started using AsyncCommands I encountered the situation where if I have a AsyncMacroCommand and one of its commands fails, the Macro keep on running.

This was problematic for me when some of the commands was depended on the failed commands and I wanted to stop the Macro flow when that happen.

So for solving that I wrote an extension to the AsyncCommand utility which I call ConditionalAsyncCommand.

I basically took the AsyncCommand and AsyncMacroCommand and added a boolean to the NextCommand method.

That way when an async command knows about a failure in the Proxy it's waiting for, it can send s onComplete(false) and that way the Macro would stop the loop.

I have 2 questions:

1. If it sounds like a valid solution for that problem? I've tested it and it works for me...

2. If it is, how can I publish it as an open source so it could benefit others (never done that before, so I don't really know about copyright issues and such)


Thanks a lot !
Shai
6  Announcements and General Discussion / Architecture / Re: Can AsyncCommands act as responders? on: November 04, 2011, 08:13:38
In your solution, you gave the observer a reference to the Command, and passed the observer to Proxy.
So the reference to the command is still "getting to the kitchen" and waiting (because of the reference to "this" in the observer)

What I wrote is a ServiceRequestVO which gets as parameters a dataObject and an IResponder,
Once the answers gets back to the Proxy, it notifies the IResponder instead of the observer.

Maybe my choice of interface was wrong, as I understand from you that the IResponder interface should be used only in the model tier.
But except for that, I'm sorry, I don't understand what is the difference in practical terms.

The first solution -> the model knows about an observer (request) (which knows about the command)
The second solution -> the model knows about a requestVO (which knows about the IResponder, AKA the command)

I just trying to understand the difference, Sorry for being hard :)
7  Announcements and General Discussion / Architecture / Re: Can AsyncCommands act as responders? on: November 04, 2011, 01:01:17
I totally get that point Cliff, and it's a good one.

I think we are talking about the same idea, but with a different implementation.

I don't want to handle the result / fault directly in the Command, I want to handle them in the Proxy and just notify the Command that it has happen.

That's why I want to pass the AsyncCommand as IResponder just to notify it's Result / Fault function only after the proxy has persisted the data.

So instead of passing an observer, I pass the AsyncCommand, and instead of notify the observer I call the "result" / "fault" function of that AsyncCommand (as IResponder).

Isn't that the same in theory ?
8  Announcements and General Discussion / Architecture / Re: Can AsyncCommands act as responders? on: November 03, 2011, 04:41:21
Thanks Cliff,

So if I get it straight, the problem with using it as a direct responder is that the "saving to a var" and "optional parsing" of the data returned from the service is in the AsyncCommand and not the Proxy.

If I'm passing the AsyncCommand as a responder, but handling the service's result / fault on the proxy and when It finishes parsing or saving the data in the proxy, It calls the IResponder's (AsyncCommand) result / fault methods, isn't it the same solution, except maybe less elegant ?

Thanks again,
Shai
9  Announcements and General Discussion / Architecture / Re: Can AsyncCommands act as responders? on: November 03, 2011, 01:25:19
First of all, Thanks for the full answer and the code examples,

It is really a pleasure to work on a framework that its founder put such great effort to help the community, Thank you Cliff !


What is the difference between this approach with using the AsyncCommand as a responder? and just passing and just implement an IResponder on the AsyncCommand (maybe subclass the AsyncCommand and create like a RequestAsyncComand) ?

What is the danger (so to speak) with using the AsyncCommand as a responder?

Thanks again Cliff for all that you do !
Shai
10  Announcements and General Discussion / Architecture / Can AsyncCommands act as responders? on: November 03, 2011, 09:52:41
I understand why SimpleCommand aren't,
But if an async command already waits for the onComplete, why can't it wait for a service call on the proxy?

So my question is if I'm calling a proxy from an AsyncCommand, and pass it the onComplete() as a callback function, is that considered a bad practice?


Thanks!
Shai
11  Announcements and General Discussion / Architecture / Re: Commands as Mini Controllers on: June 23, 2010, 07:36:27
Thanks for the quick response Cliff,

And thanks again for this great framework!
12  Announcements and General Discussion / Architecture / Commands as Mini Controllers on: June 23, 2010, 01:34:38
Hello Everyone,

I want to begin with mentioning that the PureMVC is awesome!!

A quick verification:

Is it ok to group related commands into one command, and call this command with different types to execute different sub-commands ?

An example:

I have a CreateProductsView, it has SUBMIT and INIT commands (usually there is more in my app),

I create a main Command called: "CreateProductsCommand" link it with "EXECUTE_CREATE_PRODUCTS_COMMAND" notification, and call that notification with type "INIT".

This way I can save the amount of command classes and notifications, and create a "mini controller" to that view, where if you want to look or changed anything, it is all under the same place (only in case other places doesn't need to use the same code of course)

Is it good practice? are there better ways?

Thanks,
Shai
Pages: [1]