Skip to content

useThrottledRefHistory

类别
导出体积
1.73 kB
上次更改
2 minutes ago
相关

带有节流过滤器的 useRefHistory 的简写。

示例

计数:0
/
延迟时间(毫秒):

历史记录(为演示目的限制为10条记录)
2024-09-27 02:20:06{ value: 0 }

用法

该函数在计数器的值更改后立即获取第一个快照,并在延迟 1000ms 后获取第二个快照。

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

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

类型声明

typescript
export type UseThrottledRefHistoryOptions<Raw, Serialized = Raw> = Omit<
  UseRefHistoryOptions<Raw, Serialized>,
  "eventFilter"
> & {
  throttle?: MaybeRef<number>
  trailing?: boolean
}
export type UseThrottledRefHistoryReturn<
  Raw,
  Serialized = Raw,
> = UseRefHistoryReturn<Raw, Serialized>
/**
 * 带节流功能的 useRefHistory 的简写。
 *
 * @see https://vueuse.org/useThrottledRefHistory
 * @param source
 * @param options
 */
export declare function useThrottledRefHistory<Raw, Serialized = Raw>(
  source: Ref<Raw>,
  options?: UseThrottledRefHistoryOptions<Raw, Serialized>,
): UseThrottledRefHistoryReturn<Raw, Serialized>

源码

源码演示文档

贡献者

Anthony Fu
Roman Harmyder
一纸忘忧
Anthony Fu
Jelf
Bodo Graumann
wheat

更新日志

v10.7.0 on 12/5/2023
fccf2 - feat: upgrade deps (#3614)