PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: puremvc on April 24, 2012, 07:23:46



Title: Re: Is it OK for Commands to trigger other Commands?
Post by: puremvc on April 24, 2012, 07:23:46
You can certainly do that, but remember Flash is single-threaded, so these other Commands will not be operating in parallel.

So if the theory was: 'split the data into 4 chunks and fire off 4 Notifications to deal with those chunks', then you're best off just doing the whole batch in the first Command.

However, if the theory was: 'Rather than coding 4 different processes in a single command, do each process in a separate command and execute them one after another, passing the result of one command to the next' then you're on the right track.

In fact, you could make a MacroCommand that has the 4 processing Commands as sub-commands. Each Command is executed with the same Notification instance that triggered the MacroCommand. And you can write to that note. So, Command 1 could find the data in the body of the note, execute its process and set the result back as the body of the note before finishing. Then Command 2 would receive the result of Command 1, ready to have the second process applied.

Hope this helps,
-=Cliff>