Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Welcome, Guest. Please login or register.
December 14, 2017, 10:05:04 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Author Topic: Is it OK for Commands to trigger other Commands?  (Read 3116 times)
Posts: 5

View Profile Email
« on: April 24, 2012, 06:15:47 AM »


This is a really simple one but I´ve had a search around and I can´t find anything about it.

I have a Proxy that receives some data from a server and sends a Notification that triggers a Command which then parses that data.

However, the amount of parsing is enormous and I would like to share the work. Is it OK to have the first Command do some of the work and then trigger other Commands through Notifications to finish off the job?

I´m guessing that would be fine, but I can´t find any examples of other people doing it.

Thanks in advance!
Global Moderator
Hero Member
Posts: 2871

View Profile WWW
« Reply #1 on: April 24, 2012, 07:23:46 AM »

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,
Pages: [1]
Jump to: