@@ -11,8 +11,7 @@ enum FileChangeEvent (:FileChanged(1), :FileRenamed(2));
11
11
= for code :skip-test<compile time error>
12
12
class IO::Notification {}
13
13
14
-
15
- Essentially, this class exists for the C < IO::Notification.watch-path($path) >
14
+ Essentially, this class exists as a placeholder for the C < IO::Notification.watch-path($path) >
16
15
method, that produces a L < Supply|/type/Supply >
17
16
of L < C < IO::Notification::Change > |/type/IO::Notification::Change> events for a
18
17
file or directory.
@@ -31,7 +30,35 @@ C<$path> is a directory, both modifications to the directory itself (for
31
30
example permission changes) and to files in the directory (including new
32
31
files in the directory) are reported.
33
32
34
- C < :$scheduler > allows you to specify which thread scheduler is
35
- responsible for the notification stream.
33
+ The C < :$scheduler > named argument allows you to specify which thread scheduler
34
+ is going to be responsible for the notification stream; it can be omitted if
35
+ the default scheduler is used.
36
+
37
+ = begin code
38
+ my $supply = IO::Notification.watch-path( "/var/log/syslog" );
39
+
40
+ $supply.tap( -> $v { say "Got ", $v });
41
+
42
+ sleep 60;
43
+ = end code
44
+
45
+ This snippet of code sets a watch on the system log file, emitting the kind
46
+ of event that has occurred or capturing an error otherwise; the created
47
+ C < Supply > is tapped, and the event printed. It does so for 60 minutes,
48
+ emitting something like this:
49
+
50
+ = for code
51
+ Got /var/log/syslog: FileChanged
52
+ Got /var/log/syslog: FileChanged
53
+ Got /var/log/syslog: FileChanged
54
+ Got /var/log/syslog: FileChanged
55
+ Got /var/log/syslog: FileChanged
56
+ Got /var/log/syslog: FileChanged
57
+ Got /var/log/syslog: FileChanged
58
+ Got /var/log/syslog: FileChanged
59
+
60
+ The only kind of information this method provides is the bare fact that
61
+ something has change or been renamed. You will need to actually open and read
62
+ the file or directory to check the actual changes.
36
63
37
64
= end pod
0 commit comments