Skip to content

Commit

Permalink
fix: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 30, 2020
1 parent 1440364 commit cf4fa7b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/useThrottle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function useThrottle<T>(value: Ref<T>, delay = 200) {
if (delay <= 0)
return value

const throttled = ref<T>(value.value) as Ref<T>
const throttled: Ref<T> = ref<T>(value.value as T) as Ref<T>

let timer: ReturnType<typeof setTimeout> | undefined
let hasNextValue = false
Expand All @@ -26,9 +26,9 @@ export function useThrottle<T>(value: Ref<T>, delay = 200) {
}
}

watch(value, (newVal) => {
watch(value, () => {
if (!timer) {
throttled.value = newVal
throttled.value = value.value
timer = setTimeout(timeoutCallback, delay)
}
else {
Expand Down

0 comments on commit cf4fa7b

Please sign in to comment.