Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useArrayFindLast.md
1---2category: Array3---45# useArrayFindLast67Reactive `Array.findLast`.89## Usage1011```ts12import { useArrayFindLast } from '@vueuse/core'1314const list = [ref(1), ref(-1), ref(2)]15const positive = useArrayFindLast(list, val => val > 0)16// positive.value: 217```1819### Use with reactive array2021```ts22import { useArrayFindLast } from '@vueuse/core'2324const list = reactive([-1, -2])25const positive = useArrayFindLast(list, val => val > 0)26// positive.value: undefined27list.push(10)28// positive.value: 1029list.push(5)30// positive.value: 531```3233## Type Declarations3435```ts36export type UseArrayFindLastReturn<T = any> = ComputedRef<T | undefined>37/**38* Reactive `Array.findLast`39*40* @see https://vueuse.org/useArrayFindLast41* @param list - the array was called upon.42* @param fn - a function to test each element.43*44* @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.45*46* @__NO_SIDE_EFFECTS__47*/48export declare function useArrayFindLast<T>(49list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,50fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean,51): UseArrayFindLastReturn<T>52```53