Created
November 6, 2010 09:44
-
-
Save Stray/665316 to your computer and use it in GitHub Desktop.
Map multiple events to trigger a command only when all events are received (in order if required)
This file contains hidden or 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
| // params: command, isOneShot, requireInOrder | |
| compoundCommandMap.mapToEvents(SomeAwesomeCommand, true, true) | |
| .addRequiredEvent(SomeEvent.SOMETHING_HAPPENED, SomeEvent); | |
| .addRequiredEvent(SomeOtherEvent.SOMETHING_ELSE_HAPPENED, SomeOtherEvent, 'somethingElseHappened'); | |
| .addRequiredEvent(SomeOtherEvent.STUFF_HAPPENED, SomeOtherEvent, 'stuffHappened'); | |
| // in the command itself | |
| [Inject] | |
| public var someEvent:SomeEvent; | |
| [Inject(name='somethingElseHappened')] | |
| public var somethingElseEvent:SomeOtherEvent; | |
| [Inject(name='stuffHappened')] | |
| public var stuffHappenedEvent:SomeOtherEvent; | |
| // etc - but there's a common use case where you'd only be interested in the fact that all 3 signals have fired and wouldn't need the events at all, or would only need the last one. | |
This file contains hidden or 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
| // params: command, isOneShot, requireInOrder | |
| compoundSignalCommandMap.mapToSignals(SomeAwesomeCommand, true, true) | |
| .addRequiredSignal(UserLoadedSignal); | |
| .addRequiredSignal(AccountOptionsLoadedSignal); | |
| .addRequiredSignal(PreferencesLoadedSignal); | |
| // in the command itself - most likely you'd need to use VOs so you don't have multiple | |
| // injected values of the same type | |
| [Inject] | |
| public var userVO:UserVO; | |
| [Inject] | |
| public var accountOptionsVO:AccountOptionsVO; | |
| // etc - but there's a use case where you'd only be interested in the fact that all 3 signals have fired and wouldn't need the payloads at all. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good plan