cake_wallet/lib/reactions/on_current_node_change.dart

24 lines
671 B
Dart
Raw Normal View History

2020-09-26 19:17:31 +00:00
import 'package:mobx/mobx.dart';
2021-12-24 12:37:24 +00:00
import 'package:cw_core/node.dart';
2020-09-26 19:17:31 +00:00
import 'package:cake_wallet/store/app_store.dart';
2022-10-12 17:09:57 +00:00
ReactionDisposer? _onCurrentNodeChangeReaction;
2020-09-26 19:17:31 +00:00
void startOnCurrentNodeChangeReaction(AppStore appStore) {
2022-10-12 17:09:57 +00:00
_onCurrentNodeChangeReaction?.reaction.dispose();
appStore.settingsStore.nodes.observe((change) async {
2020-09-26 19:17:31 +00:00
try {
2022-10-12 17:09:57 +00:00
await appStore.wallet!.connectToNode(node: change.newValue!);
2020-09-26 19:17:31 +00:00
} catch (e) {
print(e.toString());
}
});
2023-08-10 01:05:24 +00:00
appStore.settingsStore.powNodes.observe((change) async {
try {
await appStore.wallet!.connectToPowNode(node: change.newValue!);
} catch (e) {
print(e.toString());
}
});
2020-09-26 19:17:31 +00:00
}