Skip to content
Snippets Groups Projects
Commit 57c4bad3 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add useId utility function

parent fcc4bb35
No related branches found
No related tags found
No related merge requests found
import { computed, ComputedGetter, ComputedRef } from 'vue' import { computed, ComputedGetter, ComputedRef, readonly, ref } from 'vue'
export function computedIter<T>(fn: ComputedGetter<Iterable<T>>): ComputedRef<T[]> { export function computedIter<T>(fn: ComputedGetter<Iterable<T>>): ComputedRef<T[]> {
return computed(() => Array.from(fn())) return computed(() => Array.from(fn()))
} }
export const useId = (() => {
let _id = 0
return function useId(prefix = 'component') {
return readonly(ref(`${prefix}-${_id++}`))
}
})()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment