Async data fetching

This commit is contained in:
Yegor Vialov
2018-10-07 18:27:10 +03:00
parent e99c3f5742
commit 326cd073b9

View File

@ -123,17 +123,18 @@ class HomeAssistant {
return _connectionCompleter.future; return _connectionCompleter.future;
} }
_getData() { _getData() async {
_getConfig().then((result) { List<Future> futures = [];
_getStates().then((result) { futures.add(_getStates());
_getServices().then((result) { futures.add(_getConfig());
_getUserInfo(); futures.add(_getServices());
//futures.add(_getUserInfo());
try {
await Future.wait(futures);
_completeFetching(null); _completeFetching(null);
}); } catch (error) {
}); _completeFetching(error);
}).catchError((e) { }
_completeFetching(e);
});
} }
void _completeFetching(error) { void _completeFetching(error) {