Skip to content

Commit 23297d0

Browse files
committed
version: 2.3.0-beta.5
1 parent ce7607e commit 23297d0

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

docs/demo/useDebounceFn/demo.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
22
<div>
33
<div>Click Count:{{ valueRef }}</div>
4-
<vhp-button @click="() => run()">Click me!</vhp-button>
4+
<br />
5+
<vhp-button @click="() => (wait = 3000)">Update time 3000ms</vhp-button>
6+
<vhp-button style="margin-left: 8px;" @click="() => run()">Click me!</vhp-button>
57
</div>
68
</template>
79

@@ -10,12 +12,13 @@
1012
import { useDebounceFn } from 'vue-hooks-plus'
1113
const valueRef = ref(0)
1214
15+
const wait = ref(1000)
1316
const { run } = useDebounceFn(
1417
() => {
1518
valueRef.value += 1
1619
},
1720
{
18-
wait: 1000,
21+
wait: wait,
1922
},
2023
)
2124
</script>

packages/hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-hooks-plus",
3-
"version": "2.3.0-beta.4",
3+
"version": "2.3.0-beta.5",
44
"description": "Vue hooks library",
55
"files": [
66
"dist",

packages/hooks/src/useDebounceFn/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import debounce from 'lodash-es/debounce'
2-
import { onUnmounted, ref, watch } from 'vue'
2+
import { onUnmounted, Ref, ref, watch } from 'vue'
33

44
export interface DebounceOptions {
55
/**
66
* The number of milliseconds to delay.
77
*/
8-
wait?: number
8+
wait?: number | Ref<number, number>
99

1010
/**
1111
* Specify invoking on the leading edge of the timeout.
1212
*/
13-
leading?: boolean
13+
leading?: boolean | Ref<boolean, boolean>
1414

1515
/**
1616
* Specify invoking on the trailing edge of the timeout.
1717
*/
18-
trailing?: boolean
18+
trailing?: boolean | Ref<boolean, boolean>
1919

2020
/**
2121
* The maximum time func is allowed to be delayed before it’s invoked.
2222
*/
23-
maxWait?: number
23+
maxWait?: number | Ref<number, number>
2424
}
2525

2626
type noop = (...args: any) => any
@@ -34,6 +34,7 @@ function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
3434
const { wait = 1000, ...rest } = optionsRef.value;
3535
return debounce(fn, wait, rest);
3636
};
37+
3738
debouncedRef.value = createDebounced();
3839
watch(
3940
() => ({ ...optionsRef.value }),

pnpm-lock.yaml

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)