Created
April 27, 2012 08:40
-
-
Save simongregory/2507520 to your computer and use it in GitHub Desktop.
fluidly building a signal guard
This file contains 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
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