Created
September 7, 2012 05:15
-
-
Save softmoth/3663383 to your computer and use it in GitHub Desktop.
Registering event listeners
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
submethod BUILD (:$events!) { | |
$events.listen: | |
'EOF' => { | |
# Safety to prevent infinite loop, in case | |
# the quit-on-undef logic fails | |
unless $*IN.eof { | |
my $input = prompt("\n> "); | |
$events.emit('command', :$input); | |
} | |
}, | |
'quit' => { say "Goodbye!" }, | |
'exit' => { exit }, | |
'no-parse' => { print @begYourPardon.pick; }, | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment