Skip to content
Snippets Groups Projects
util.ts 354 B
Newer Older
  • Learn to ignore specific revisions
  • import { computed, ComputedGetter, ComputedRef, readonly, ref } from 'vue'
    
    
    export function computedIter<T>(fn: ComputedGetter<Iterable<T>>): ComputedRef<T[]> {
      return computed(() => Array.from(fn()))
    }
    
    
    export const useId = (() => {
      let _id = 0
      return function useId(prefix = 'component') {
        return readonly(ref(`${prefix}-${_id++}`))
      }
    })()