import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/src/domain/common/transaction_info.dart'; abstract class TransactionHistoryBase { TransactionHistoryBase() : _isUpdating = false; @observable ObservableMap transactions; bool _isUpdating; Future update() async { if (_isUpdating) { return; } try { _isUpdating = false; transactions.addAll(await fetchTransactions()); _isUpdating = true; } catch (e) { _isUpdating = false; rethrow; } } void updateAsync({void Function() onFinished}) { fetchTransactionsAsync( (transaction) => transactions[transaction.id] = transaction, onFinished: onFinished); } void fetchTransactionsAsync( void Function(TransactionType transaction) onTransactionLoaded, {void Function() onFinished}); Future> fetchTransactions(); }