R
fn

useThrottledRefHistory

v0.0.15testeddemo

Shorthand for {@link useRefHistory} with a throttled event filter, so rapid source changes are committed at most once per interval (trailing edge by default).

Examples

ts
const count = ref(0);
const { history, undo, redo } = useThrottledRefHistory(count, { throttle: 1000 });

count.value = 1;
count.value = 2;
count.value = 3; // collapsed into a single throttled commit
ts
// Reactive interval and deep tracking
const ms = ref(500);
const state = ref({ items: [] });
const { history } = useThrottledRefHistory(state, { throttle: ms, deep: true });

Demo

Loading demo…

Signature

ts
export function useThrottledRefHistory<Raw, Serialized = Raw>(
  source: Ref<Raw>,
  options: UseThrottledRefHistoryOptions<Raw, Serialized> ={ ... }

Type Parameters

Raw
Serialized= Raw

Parameters

ParameterTypeDescription
sourceRef<Raw, Raw>The ref whose changes are tracked
options?UseThrottledRefHistoryOptions<Raw, Serialized>Tracking options — all of {@link useRefHistory}'s except `eventFilter`, plus `throttle`, `trailing`, and `leading`

Returns

UseRefHistoryReturn<Raw, Serialized>History records plus `undo`/`redo`/`commit`/`reset`/`clear`/`pause`/`resume`/`batch`/`dispose`