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

TxCustomStore.

Adapter for custom synchronous or asynchronous store callbacks. Operations without callbacks are unavailable.

load is required; byKey/insert/update/remove are optional. load receives TxLoadOptions and returns TxLoadResult directly or asynchronously. Custom HTTP callbacks must check status codes and propagate failures. byKey returns undefined/null for a missing record. For paging, return data and totalCount before paging. With remoteOperations false, return all raw data. The example uses a local async callback and requires no server.

ts
new TxCustomStore<T>(callbacks: TxStore<T>): TxCustomStore<T>
MemberType / returnBehavior
load(options: TxLoadOptions<T>) => TxLoadResult<T> | Promise<TxLoadResult<T>>Loads using the supplied options; DataSource uses current query state without arguments. Errors propagate.
byKey((key: TxKey) => T | Promise<T | undefined> | undefined) | undefinedReads a record by key; missing keys return undefined (Vue) or null (Dart).
insert((item: T) => T | Promise<T>) | undefinedInserts a record with a unique key and returns it.
update((key: TxKey, changes: Partial<T>) => T | Promise<T>) | undefinedUpdates a notification or record.
remove((key: TxKey) => Promise<void> | void) | undefinedRemoves the record or recursively removes a file/directory tree.
ts
import { TxCustomStore, txQuery } from '@tekocloud.de/tecexpress'
// Replace callbacks with your own HTTP/database integration.
const store = new TxCustomStore<{ id: number }>({ load: async options => txQuery([{ id: 1 }], options), byKey: async id => id === 1 ? { id: 1 } : undefined })
console.log(await store.load({}), await store.byKey?.(1))