My App downloads some info from server. At the begining I check the Internet connection then start job like:
... checkConnection{ val data = withContext(Dispatchers.IO) { Repo.getInfo() } } ... fun checkConnection( block: ()-> Unit){ ...//check if (hasConnection) block() else showSnackbarInternetError() }
- Check connection and start Repo.getInfo()
- During job Internet has been lost
- Job is suspended until Internet will appear
How should I check Internet connection with started job?
Perhaps, should I create some InternetListener?