Skip to content

useThrottledRefHistory

Category
Export Size
1.73 kB
Last Changed
15 minutes ago
Related

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

Demo

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

历史记录(为演示目的限制为10条记录)
2024-10-31 08:41:19{ 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>

Source

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Roman Harmyder
Anthony Fu
Jelf
Bodo Graumann
wheat

变更日志

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

Released under the MIT License.