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

TxArrayStore.

Copied in-memory collection with local queries and key-based CRUD operations.

Vue: data = [], key = "id". Dart: data is required; without keyOf only queries are supported. Construction copies the list. Duplicate keys, insertion of existing keys and key changes are rejected. update/remove with an unknown key fail; byKey returns undefined/null.

TxArrayStore

ParameterTypeDefaultMeaning
dataList<T>requiredRecords or event payload.
keyOfTxKeyOf<T>?nullReads the stable record key.
Member / type / returnMeaning
List<T> get dataRecords or event payload.
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.
TxLoadResult<T> load(TxLoadOptions<T> options)Loads using the supplied options; DataSource uses current query state without arguments. Errors propagate.
T? byKey(Object key)Reads a record by key; missing keys return undefined (Vue) or null (Dart).
T insert(T item)Inserts a record with a unique key and returns it.
T update(Object key, T Function(T) change)Updates a notification or record.
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 = TxArrayStore<Map<String, Object>>([{'id': 1}], keyOf: (row) => row['id']!);
  print(store.load(const TxLoadOptions()));
  print(store.byKey(1));
  store.insert({'id': 2});
  store.update(2, (row) => {...row, 'name': 'Two'});
  store.remove(2);
}