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: Merging/combining commands?  (Read 8975 times)
Bill
Newbie
*
Posts: 3


View Profile Email
« on: January 06, 2010, 10:04:35 »

Hi,

How can you merge or combine commands in PureMVC?

Reason:
I make use of the AS3 Undo utility, and want to put multiple commands in one single undo command.
Now you have the initializeMacroCommand method, but then you have to know upfront what commands you wanna combine. What if you only know at runtime (by means of notifications) which commands you want to combine? It doesn't seem possible with pureMVC out-of-the-box, so you would have to create a helper class  to keep track of things right?
Furthermore, in the flight framework this is implemented through the IMergingCommand interface, so probably an idea for an enhancement to PureMVC?

Regards,

Bill
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 08, 2010, 11:09:55 »

I checked out the IMergingCommand interface. I don't see it as a useful enhancement for the framework itself, but more reasonably for the Undo Utility, since the goal is to merge multiple commands into one for undo/redo.

If you're of a mind to consider how it might be done, you can always have a crack at it yourself or you can also communicate with the author of the Undo utility dragos.dascalita at puremvc.org

-=Cliff>
Logged
Bill
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: January 08, 2010, 03:09:12 »

Seems logical

I'll try contacting Dragos to see if he can give some advice.

Thanks

Bill
Logged
ddragosd
Courseware Beta
Jr. Member
***
Posts: 10


View Profile Email
« Reply #3 on: January 08, 2010, 05:20:34 »

When you merge multiple commands, those commands could also be UndoableCommands ?

And if you plan to merge them at runtime, how do you plan to store the information about which commands merge with what ? If you override initializeMacroCommand that won't help ? You can't use notification's body to find out the subcommands you want to run ?

Also, do you want to run the commands sequentially or in parallel ?
Logged
Bill
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: January 09, 2010, 01:36:06 »

When you merge those commands, those commands should be different I guess.

I'm not sure how it should work, but if you look at the implementation in the Flight Framework, those commands are ICombinableCommand. There's a manager class called CommandHistory. Within the executeCommand of this class a class variable "mergingCommand" is instantiated whenever there's a combinable command (much like the undoCmdClass). But how the Flight Framework deals with multiple combining or storage of the commands is not clear to me, it seems to me that they are linked through one another through the class variable "mergingCommand"?

overriding the initializeMacroCommand is not working, since this method is called on instantiation of the class, while you really want to be able to execute the combined commands each time you are undoing several commands combined.

using notifications is not possible either since you have no reference to the previous command

It is supposed to run the commands sequentially and in reverse order.

If you look at the undo-textfields project you can see an example of combining undo commands
into one undo command using flight framework 0.8
http://code.google.com/p/undo-textfields/




Logged
Pages: [1]
Print