useThrottledRefHistory
スロットルフィルタを適用したuseRefHistory
の省略形。
デモ
使用方法
この関数は、カウンターの値が変更された直後の最初のスナップショットと、1000ミリ秒の遅延を伴う2番目のスナップショットを取得します。
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>
/**
* Shorthand for [useRefHistory](https://vueuse.dokyumento.jp/useRefHistory) with throttled filter.
*
* @see https://vueuse.dokyumento.jp/useThrottledRefHistory
* @param source
* @param options
*/
export declare function useThrottledRefHistory<Raw, Serialized = Raw>(
source: Ref<Raw>,
options?: UseThrottledRefHistoryOptions<Raw, Serialized>,
): UseThrottledRefHistoryReturn<Raw, Serialized>