sendChunks<TVal> method
Method for sending large data by chunks
Implementation
@protected
Future<void> sendChunks<TVal>(TEvent eventId, List<TVal> values,
{int itemsPerChunk = 100, Duration delay = const Duration(milliseconds: 16), bool updateAfterFirstChunk = false}) async {
final String eventIdString = '$eventId';
if (_activeTransactions.any((String transactionCode) => Utils.getIdFromCode(transactionCode) == eventIdString)) {
/// Delete code of old, now ended transaction
final List<String> oldCodes = _activeTransactions.where((String transactionCode) => Utils.getIdFromCode(transactionCode) == eventIdString).toList();
oldCodes.forEach((String oldCode) => _activeTransactions.remove(oldCode));
await Future<void>.delayed(delay);
}
final String currentTransactionCode = Utils.generateCode(eventId);
_activeTransactions.add(currentTransactionCode);
await _transactionRunner(eventId, values,
transactionCode: currentTransactionCode, itemsPerChunk: itemsPerChunk, delay: delay, updateAfterFirstChunk: updateAfterFirstChunk);
}