IO::Notification Reference
Asynchronous notification for file and directory changes
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method watch-path #
method watch-path(IO::Notification: Str() $path, :$scheduler = $*SCHEDULER)
Returns a Supply that emits IO::Notification::Change objects. If $path is a file, only modifications of that file are reported. If $path is a directory, both modifications to the directory itself (for example permission changes) and to files in the directory (including new files in the directory) are reported. The :$scheduler named argument allows you to specify which thread scheduler
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
4 no-output
enum FileChangeEvent (:FileChanged(1), :FileRenamed(2));
Not executed: the documentation states no expected output for this example.
class IO::Notification {}Not executed: the documentation states no expected output for this example.
my $supply = IO::Notification.watch-path( "/var/log/syslog" );
$supply.tap( -> $v { say "Got ", $v });
sleep 60;Not executed: the documentation states no expected output for this example.
Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged Got /var/log/syslog: FileChanged
Not executed: the documentation states no expected output for this example.