RxPaginatedImpl<K, T, V, C> constructor

RxPaginatedImpl<K, T, V, C>({
  1. required FutureOr<T?> transform({
    1. required V data,
    2. T? previous,
    }),
  2. required Pagination<V, C, K> pagination,
  3. List<FutureOr<Map<K, T>>> initial = const [],
  4. K? initialKey,
  5. C? initialCursor,
  6. void onDispose()?,
})

Implementation

RxPaginatedImpl({
  required this.transform,
  required Pagination<V, C, K> super.pagination,
  super.initial,
  super.initialKey,
  super.initialCursor,
  super.onDispose,
}) {
  // TODO: Replace completely with bug-free [_apply]ing of items right away.
  _paginationSubscription = pagination!.changes.listen((event) async {
    switch (event.op) {
      case OperationKind.added:
      case OperationKind.updated:
        await _apply(event.key as K, event.value as V);
        break;

      case OperationKind.removed:
        items.remove(event.key);
        break;
    }
  });
}