Last active
September 4, 2015 12:32
-
-
Save muraiki/222814d5928f648be3c1 to your computer and use it in GitHub Desktop.
Watch source files using Supplies
This file contains hidden or 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
# disclaimer: I'm a perl6 noob :) | |
my $out = Supply.new; | |
$out.act: -> $s { say $s }; # actor model semantics; only ever execute this in 1 thread | |
my $watcher = IO::Notification.watch-path($*CWD.abspath)\ | |
.grep(*.event.isa(FileChangeEvent::FileChanged))\ | |
.unique(:as(*.path), :expires(1))\ # unique paths over last second, to prevent double-triggering from metadata events | |
.map(*.path.IO)\ # convert event path strings to IO::Path objects | |
.grep(*.extension eq 'p6')\ | |
.tap(-> $path { $out.emit: "Source file changed: {$path.basename}" }); | |
sleep; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can construct any number of arbitrary watchers, which will operate concurrently.