mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
* refactor(fs-watch): make options arg optional, closes #3 * fmt * readme
This commit is contained in:
@@ -56,18 +56,18 @@ import { watch, watchImmediate } from "tauri-plugin-fs-watch-api";
|
||||
// can also watch an array of paths
|
||||
const stopWatching = await watch(
|
||||
"/path/to/something",
|
||||
{ recursive: true },
|
||||
(event) => {
|
||||
const { type, payload } = event;
|
||||
}
|
||||
},
|
||||
{ recursive: true }
|
||||
);
|
||||
|
||||
const stopRawWatcher = await watchImmediate(
|
||||
["/path/a", "/path/b"],
|
||||
{},
|
||||
(event) => {
|
||||
const { path, operation, cookie } = event;
|
||||
}
|
||||
},
|
||||
{}
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ async function unwatch(id: number): Promise<void> {
|
||||
|
||||
export async function watch(
|
||||
paths: string | string[],
|
||||
options: DebouncedWatchOptions,
|
||||
cb: (event: DebouncedEvent) => void
|
||||
cb: (event: DebouncedEvent) => void,
|
||||
options: DebouncedWatchOptions = {}
|
||||
): Promise<UnlistenFn> {
|
||||
const opts = {
|
||||
recursive: false,
|
||||
@@ -82,8 +82,8 @@ export async function watch(
|
||||
|
||||
export async function watchImmediate(
|
||||
paths: string | string[],
|
||||
options: WatchOptions,
|
||||
cb: (event: RawEvent) => void
|
||||
cb: (event: RawEvent) => void,
|
||||
options: WatchOptions = {}
|
||||
): Promise<UnlistenFn> {
|
||||
const opts = {
|
||||
recursive: false,
|
||||
|
||||
Reference in New Issue
Block a user