File tree 4 files changed +8
-4
lines changed
4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ $watcher->watch(
32
32
function (FsNotify\Event $event) {
33
33
var_dump($event->getKind()); // kind of file/folder event
34
34
var_dump($event->getPaths()); // paths
35
+ return true; // return false if you do not want to continue
35
36
}
36
37
);
37
38
```
@@ -50,7 +51,7 @@ class RecommendedWatcher
50
51
public function remove(string $path): void;
51
52
52
53
/**
53
- * @param callable(Event): void $handle
54
+ * @param callable(Event): bool $handle
54
55
* @throws WatchException
55
56
*/
56
57
public function watch(callable $handle): void;
Original file line number Diff line number Diff line change @@ -190,7 +190,10 @@ pub fn get_module() -> Module {
190
190
let kind = php_event. get_mut_property ( "kind" ) ;
191
191
* kind = php_kind. into ( ) ;
192
192
193
- handler. call ( [ ZVal :: from ( php_event) ] ) ?;
193
+ let call_result = handler. call ( [ ZVal :: from ( php_event) ] ) ?;
194
+ if call_result. expect_bool ( ) ? == false {
195
+ break ;
196
+ }
194
197
} ,
195
198
Err ( error) => return Err ( NotifyError :: new ( error) . into ( ) ) ,
196
199
}
Original file line number Diff line number Diff line change 12
12
$ watcher ->watch (function (FsNotify \Event $ event ) {
13
13
var_dump ($ event ->getKind ());
14
14
var_dump ($ event ->getPaths ());
15
- exit ;
15
+ return false ;
16
16
});
Original file line number Diff line number Diff line change 7
7
try {
8
8
$ watcher = new FsNotify \RecommendedWatcher ();
9
9
$ watcher ->add (__DIR__ . '/unknown ' );
10
- $ watcher ->watch (fn () => null );
10
+ $ watcher ->watch (fn () => false );
11
11
} catch (FsNotify \WatchException ) {
12
12
echo "caught exception " ;
13
13
}
You can’t perform that action at this time.
0 commit comments