Stray
unread,Jul 24, 2012, 7:29:33 AM7/24/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to robo...@googlegroups.com
If you map multiple commands, with guards and/or hooks, to the same event, the current order of execution is:
1. Event is mapped for injection.
2. All guards executed in the order in which they were mapped.
3. Commands that the guards approved are created, hooks are run on those commands.
4. Event is unmapped for injection.
5. All commands are executed, in the order in which they were mapped.
This order prevents the event injection from 'leaking' into any work your command does.
However, Neil Manuell had instinctively imagined that the order would be:
Guard checked -> Command Created -> Hooks run -> Command executed
for each consecutive command in the order in which they were created. So - crucially, the first command has executed before the second guard is created.
Neil had intended to provide some mappings in the first command mapped, which are then used by the guards and commands that come later.
As you can see on his thread in issues, I was initially not sure that it's correct to change things to do what he expected.
However - having slept on it, I think perhaps if that's the 'least surprising' behaviour, then that's what we should go for.
Of course there are ways to achieve either behaviour yourself by dispatching custom events etc, but I wanted to check with the group.
The increased overhead would be that the event would be unmapped and remapped for each command, as we don't want the event mapping to persist during command execution.
Thoughts? What did you imagine the execution order would be?
Stray