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

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.

TxCustomStore

ParameterTypeDefaultMeaning
loadFutureOr<TxLoadResult<T>> Function(TxLoadOptions<T>)requiredLoads using the supplied options; DataSource uses current query state without arguments. Errors propagate.
byKeyFutureOr<T?> Function(Object)?nullReads a record by key; missing keys return undefined (Vue) or null (Dart).
insertFutureOr<T> Function(T)?nullInserts a record with a unique key and returns it.
updateFutureOr<T> Function(Object, T Function(T))?nullUpdates a notification or record.
removeFutureOr<void> Function(Object)?nullRemoves the record or recursively removes a file/directory tree.
Member / type / returnMeaning
bool get canByKeyWhether the store supports ByKey.
bool get canInsertWhether the store supports Insert.
bool get canUpdateWhether the store supports Update.
bool get canRemoveWhether the store supports Remove.
FutureOr<TxLoadResult<T>> load(TxLoadOptions<T> options)Loads using the supplied options; DataSource uses current query state without arguments. Errors propagate.
FutureOr<T?> byKey(Object key)Reads a record by key; missing keys return undefined (Vue) or null (Dart).
FutureOr<T> insert(T item)Inserts a record with a unique key and returns it.
FutureOr<T> update(Object key, T Function(T) change)Updates a notification or record.
FutureOr<void> remove(Object key)Removes the record or recursively removes a file/directory tree.
dart
import 'package:tecexpress/tecexpress.dart';

Future<void> example() async {
  final store = TxCustomStore<int>(load: (options) async => txQuery([1, 2], options), byKey: (key) => key == 1 ? 1 : null);
  print(await store.load(const TxLoadOptions()));
}