Skip to content
On this page

useLastChanged

Category
Export Size
218 B
Last Changed
last year

Records the timestamp of the last change

Demo

Last changed: 5 minutes ago (1671541230144)

Usage

ts
import { useLastChanged } from '@vueuse/core'

const a = ref(0)

const lastChanged = useLastChanged(a)

a.value = 1

console.log(lastChanged.value)
import { useLastChanged } from '@vueuse/core'

const a = ref(0)

const lastChanged = useLastChanged(a)

a.value = 1

console.log(lastChanged.value)

Type Declarations

typescript
export interface UseLastChangedOptions<
  Immediate extends boolean,
  InitialValue extends number | null | undefined = undefined
> extends WatchOptions<Immediate> {
  initialValue?: InitialValue
}
/**
 * Records the timestamp of the last change
 *
 * @see https://vueuse.org/useLastChanged
 */
export declare function useLastChanged(
  source: WatchSource,
  options?: UseLastChangedOptions<false>
): Ref<number | null>
export declare function useLastChanged(
  source: WatchSource,
  options: UseLastChangedOptions<true>
): Ref<number>
export declare function useLastChanged(
  source: WatchSource,
  options: UseLastChangedOptions<boolean, number>
): Ref<number>
export interface UseLastChangedOptions<
  Immediate extends boolean,
  InitialValue extends number | null | undefined = undefined
> extends WatchOptions<Immediate> {
  initialValue?: InitialValue
}
/**
 * Records the timestamp of the last change
 *
 * @see https://vueuse.org/useLastChanged
 */
export declare function useLastChanged(
  source: WatchSource,
  options?: UseLastChangedOptions<false>
): Ref<number | null>
export declare function useLastChanged(
  source: WatchSource,
  options: UseLastChangedOptions<true>
): Ref<number>
export declare function useLastChanged(
  source: WatchSource,
  options: UseLastChangedOptions<boolean, number>
): Ref<number>

Source

SourceDemoDocs

Contributors

Anthony Fu
Alex Kozack

Changelog

No recent changes

Released under the MIT License.