Skip to content

Commit

Permalink
Update README.md (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Nov 26, 2021
1 parent a7f5d00 commit 2f2a858
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -21,12 +21,20 @@ npm install fsevents

```js
const fsevents = require('fsevents');

// To start observation
const stop = fsevents.watch(__dirname, (path, flags, id) => {
const info = fsevents.getInfo(path, flags, id);
}); // To start observation
stop(); // To end observation
});

// To end observation
stop();
```

> **Important note:** The API behaviour is slightly different from typical JS APIs. The `stop` function **must** be
> retrieved and stored somewhere, even if you don't plan to stop the watcher. If you forget it, the garbage collector
> will eventually kick in, the watcher will be unregistered, and your callbacks won't be called anymore.
The callback passed as the second parameter to `.watch` get's called whenever the operating system detects a
a change in the file system. It takes three arguments:

Expand Down

0 comments on commit 2f2a858

Please sign in to comment.