Skip to content

useDebouncedRefHistory

Category
Export Size
1.7 kB
Last Changed
15 minutes ago
Related

具有防抖过滤器的 useRefHistory 的简写。

Demo

Count: 0
/
延迟(毫秒):

历史记录(仅限演示,最多保存10条记录)
2024-10-31 08:41:17{ value: 0 }

用法

此函数在计数器值开始变化时,会在 1000ms 后对其进行快照。

ts
import { useDebouncedRefHistory } from '@vueuse/core'
import { ref } from 'vue'

const counter = ref(0)
const { history, undo, redo } = useDebouncedRefHistory(counter, { deep: true, debounce: 1000 })

类型声明

typescript
/**
 * [useRefHistory](https://vueuse.org/useRefHistory) 的防抖实现
 *
 * @see https://vueuse.org/useDebouncedRefHistory
 * @param source
 * @param options
 */
export declare function useDebouncedRefHistory<Raw, Serialized = Raw>(
  source: Ref<Raw>,
  options?: Omit<UseRefHistoryOptions<Raw, Serialized>, "eventFilter"> & {
    debounce?: MaybeRefOrGetter<number>
  },
): UseRefHistoryReturn<Raw, Serialized>

Source

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Roman Harmyder
Anthony Fu
wheat

变更日志

v10.0.0-beta.4 on 4/13/2023
4d757 - feat(types)!: rename MaybeComputedRef to MaybeRefOrGetter

Released under the MIT License.