-
-
Save muraiki/f0b2b0c2a9e2aa370970 to your computer and use it in GitHub Desktop.
two greps on one supply
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
# When two greps are used on one supply, the one that matches is triggered twice. | |
# Run the following, then in the same directory `touch watchfile` | |
# Output: | |
# got file change: "watchfile" | |
# got file change: "watchfile" | |
# Expected output should only be a single line, not two. | |
# Each additional grep I add to the supply yields an additional output line. | |
my $paths = IO::Notification.watch_path('.')\ | |
.grep(*.event.isa(FileChangeEvent::FileChanged))\ | |
.unique(:as(*.path), :expires(5))\ | |
.map(*.path); | |
my $watch = $paths.grep(* ~~ /watchfile/)\ | |
.act(-> $x { | |
say "got file change: " ~ $x.perl; | |
}); | |
my $never = $paths.grep(* ~~ /shouldneverexecute/)\ | |
.act(-> $x { | |
say "should never execute: " ~ $x.perl; | |
}); | |
sleep; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I also tried testing this without using IO::Notification, and could not reproduce the bug.