sendChunks<TVal> method

  1. @protected
Future<void> sendChunks<TVal>(
  1. TEvent eventId,
  2. List<TVal> values, {
  3. int itemsPerChunk = 100,
  4. Duration delay = const Duration(milliseconds: 16),
  5. bool updateAfterFirstChunk = false,
})

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);
}