Skip to content

Instantly share code, notes, and snippets.

@simongregory
Created April 27, 2012 08:40
Show Gist options
  • Save simongregory/2507520 to your computer and use it in GitHub Desktop.
Save simongregory/2507520 to your computer and use it in GitHub Desktop.
fluidly building a signal guard
package bbc.core.guard
{
public class SignalGuard
{
public function fire(signal:ISignal):SignalGuard
{
_destination = signal
return build()
}
public function when(signal:ISignal):SignalGuard
{
_origin = signal
return build()
}
public function unless(guard:Function):SignalGuard
{
_guard = guard
return build()
}
private function build():SignalGuard
{
if(_origin && _destination && _guard)
{
addGuardedSignal(_origin, _destination, _guard)
_origin = _destination = _guard = null
return null
}
return this
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment