tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/153-guards-hooks-and-payloadRobotlegs: Discussion 2012-10-24T07:39:14Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/196936782012-10-16T20:07:22Z2012-10-16T20:07:42ZGuards, Hooks and payload<div><p>Hi Quentin,</p>
<p>These are concepts to act without parameters.
<code>Guards</code> checks for current state of application and
tells if an action can be executed (they don't know anything about
what action), e.g. <code>NoPopupOpenGuard</code> checks if there
are any popups open and if yes it doesn't agree for action to be
executed (commands for most cases).</p>
<p>The same goes for <code>Hooks</code>, but they act when the
action is allowed to be executed (not sure exactly when, before or
after <code>Command</code>). It can be hooked to the command, like
post-process, e.g. <code>RemoveCurrentPopupHooks</code></p>
<p>Hope it helps,<br>
Michał</p></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/196936782012-10-16T20:24:14Z2012-10-16T20:24:14ZGuards, Hooks and payload<div><p>It helps yeah, thanks!<br>
So I guess what I'm looking for is a command with a simple if
condition in it.</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/196936782012-10-16T20:51:56Z2012-10-16T20:52:48ZGuards, Hooks and payload<div><p>Exactly :) Of course if it depends on command parameters. If
it's a state check - use guards</p></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/196936782012-10-19T09:13:45Z2012-10-19T09:13:45ZGuards, Hooks and payload<div><p>BTW, I have been using @stray's OnlyIf... notation for
guards<br>
so <code>NoPopupOpenGuard</code> becomes
<code>OnlyIfNoPopUpsOpen</code></p>
<p>also Hooks are called post construct of Command, but just before
execute is called.</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/196936782012-10-19T09:19:04Z2012-10-19T09:19:04ZGuards, Hooks and payload<div><p>Thanks Neil for the input!</p></div>Michal Wroblewski