Guards, Hooks and payload

Quentin's Avatar

Quentin

16 Oct, 2012 02:34 PM

Hey everyone!
I'm using RL2 and playing with Guards and Hooks. They're both very good concepts but I don't understand how/if they receive events/signals payload objects.

I'm using the SignalCommandMap extension, and when I dispatch signals with payloads the Commands receive them but the Guards don't...

Are they designed to?
If so, is it implemented?
If so, I can't get it to work!

Thanks!

  1. 1 Posted by Michal Wroblews... on 16 Oct, 2012 08:07 PM

    Michal Wroblewski's Avatar

    Hi Quentin,

    These are concepts to act without parameters. Guards checks for current state of application and tells if an action can be executed (they don't know anything about what action), e.g. NoPopupOpenGuard checks if there are any popups open and if yes it doesn't agree for action to be executed (commands for most cases).

    The same goes for Hooks, but they act when the action is allowed to be executed (not sure exactly when, before or after Command). It can be hooked to the command, like post-process, e.g. RemoveCurrentPopupHooks

    Hope it helps,
    Michał

  2. 2 Posted by Quentin on 16 Oct, 2012 08:24 PM

    Quentin's Avatar

    It helps yeah, thanks!
    So I guess what I'm looking for is a command with a simple if condition in it.

  3. 3 Posted by Michal Wroblews... on 16 Oct, 2012 08:51 PM

    Michal Wroblewski's Avatar

    Exactly :) Of course if it depends on command parameters. If it's a state check - use guards

  4. 4 Posted by neil on 19 Oct, 2012 09:13 AM

    neil's Avatar

    BTW, I have been using @stray's OnlyIf... notation for guards
    so NoPopupOpenGuard becomes OnlyIfNoPopUpsOpen

    also Hooks are called post construct of Command, but just before execute is called.

  5. 5 Posted by Michal Wroblews... on 19 Oct, 2012 09:19 AM

    Michal Wroblewski's Avatar

    Thanks Neil for the input!

  6. Ondina D.F. closed this discussion on 24 Oct, 2012 07:39 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac