From 92b01ea05020e431a13ab96a1c0402be7877279e Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Thu, 27 Apr 2023 12:23:49 +0200 Subject: [PATCH] refactor(fs-watch): make options arg optional, closes #3 (#334) * refactor(fs-watch): make options arg optional, closes #3 * fmt * readme --- plugins/fs-watch/README.md | 8 ++++---- plugins/fs-watch/guest-js/index.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/fs-watch/README.md b/plugins/fs-watch/README.md index 8162d1fe..59729b4d 100644 --- a/plugins/fs-watch/README.md +++ b/plugins/fs-watch/README.md @@ -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; - } + }, + {} ); ``` diff --git a/plugins/fs-watch/guest-js/index.ts b/plugins/fs-watch/guest-js/index.ts index 31d333b2..05ed07e5 100644 --- a/plugins/fs-watch/guest-js/index.ts +++ b/plugins/fs-watch/guest-js/index.ts @@ -44,8 +44,8 @@ async function unwatch(id: number): Promise { export async function watch( paths: string | string[], - options: DebouncedWatchOptions, - cb: (event: DebouncedEvent) => void + cb: (event: DebouncedEvent) => void, + options: DebouncedWatchOptions = {} ): Promise { 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 { const opts = { recursive: false,