Created
July 31, 2011 16:26
-
-
Save alecmce/1116928 to your computer and use it in GitHub Desktop.
strategies for mapping values and executing commands in RobotLegs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. github.com/robotlegs/robotlegs-framework/blob/master/src/org/robotlegs/base/CommandMap.as: | |
// only one mapping possible | |
mapValues(); | |
command = createCommand(mapping); | |
unmapValues(); | |
command.execute(); | |
2. github.com/joelhooks/signals-extensions-CommandSignal/blob/master/src/org/robotlegs/base/SignalCommandMap.as: | |
// multiple mappings possible | |
for each mapping | |
{ | |
mapValues(); | |
createCommand(mapping).execute(); | |
unmapValues(); | |
} | |
2a. occurs to me that following the pattern in 1, 2 should be: | |
for each mapping | |
{ | |
mapValues(); | |
command = createCommand(mapping); | |
unmapValues(); | |
command.execute(); | |
} | |
3. I was originally thinking about the case where I maintain own list of mapped commands: | |
mapValues() | |
for each mapping | |
{ | |
createCommand(mapping).execute(); | |
} | |
unmapValues(); | |
4. but thinking about 2a this seems better: | |
commands = new Vector(commandCount, true); | |
mapValues(); | |
for each mapping | |
{ | |
commands.push(createCommand(mapping)); | |
} | |
unmapValues(); | |
for each command | |
{ | |
command.execute(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent. And - in addition, you've revealed that the current implementation of the event driven command map doesn't leave the mappings while the command is executed. I have a version that does, so I'm guessing that has been lost along the line and we don't have good tests for it. I'll add those!
Thanks - always worth asking the question because there are so many opportunities for assumptions... looks like we've found one here, even if it wasn't the droid you were looking for.