t×tecexpressby TeKOcloud
DEv0.7.1
API & types / VUE

useTxSource.

Vue composable exposing reactive items/source/loading/error/revision refs. Call inside setup; borrowed instances are not disposed.

Parameters: getSource reads the current binding; optional fallback returns a fallback list (default []). Returns items/source/loading/error/revision as Vue refs. Lifecycle hooks require setup. Unmount removes listeners and disposes only instances created from configurations.

ts
function useTxSource<T>(getSource: () => TxSource<T> | undefined, fallback?: () => T[]): { items: ComputedRef<T[]>; source: ShallowRef<TxDataSource<T> | undefined, TxDataSource<T> | undefined>; loading: ComputedRef<boolean>; error: ComputedRef<unknown>; revision: ShallowRef<number, number>; }
ts
import { defineComponent, h } from 'vue'
import { useTxSource } from '@tekocloud.de/tecexpress'
export default defineComponent({ setup() {
  const rows = [{ id: 1, text: 'One' }]
  const { items, loading, error, source, revision } = useTxSource(() => rows)
  return () => h('p', error.value ? String(error.value) : `${items.value.length} / ${loading.value} / ${revision.value} / ${!!source.value}`)
} })