Async data fetching
This commit is contained in:
@ -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());
|
||||||
_completeFetching(null);
|
//futures.add(_getUserInfo());
|
||||||
});
|
try {
|
||||||
});
|
await Future.wait(futures);
|
||||||
}).catchError((e) {
|
_completeFetching(null);
|
||||||
_completeFetching(e);
|
} catch (error) {
|
||||||
});
|
_completeFetching(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _completeFetching(error) {
|
void _completeFetching(error) {
|
||||||
|
Reference in New Issue
Block a user