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.
new TxCustomStore<T>(callbacks: TxStore<T>): TxCustomStore<T>| Member | Type / return | Behavior |
|---|---|---|
| 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) | undefined | Reads a record by key; missing keys return undefined (Vue) or null (Dart). |
| insert | ((item: T) => T | Promise<T>) | undefined | Inserts a record with a unique key and returns it. |
| update | ((key: TxKey, changes: Partial<T>) => T | Promise<T>) | undefined | Updates a notification or record. |
| remove | ((key: TxKey) => Promise<void> | void) | undefined | Removes the record or recursively removes a file/directory tree. |
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))