cake_wallet/lib/core/transaction_history.dart

28 lines
638 B
Dart
Raw Normal View History

2020-06-01 18:13:56 +00:00
import 'package:mobx/mobx.dart';
2020-06-20 07:10:00 +00:00
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
2020-06-01 18:13:56 +00:00
2020-06-20 07:10:00 +00:00
abstract class TransactionHistoryBase<TransactionType extends TransactionInfo> {
TransactionHistoryBase() : _isUpdating = false;
2020-06-01 18:13:56 +00:00
@observable
2020-06-20 07:10:00 +00:00
ObservableList<TransactionType> transactions;
2020-06-01 18:13:56 +00:00
bool _isUpdating;
Future<void> update() async {
if (_isUpdating) {
return;
}
try {
_isUpdating = false;
2020-06-20 07:10:00 +00:00
transactions.addAll(await fetchTransactions());
2020-06-01 18:13:56 +00:00
_isUpdating = true;
} catch (e) {
_isUpdating = false;
rethrow;
}
}
Future<List<TransactionType>> fetchTransactions();
}