Open TranceLove opened 3 years ago
Related #2668
I don't think that keeping the "onPreExcecute, doInBackground, publishProgress, onPostExecute" all in one file is a good idea. I've started moving the "doInBackground" part to another file, as a callable, and everything else into a "Task", and I've separated the "onPostExcecute" into "onFinish" and "onError", this allows for tasks to fail without crashing the app.
All this was done using ReactiveX (RxAndroid). If the above model can be kept when moving to coroutines it would be a good idea IMO.
Perhaps this convenient class may help too: https://medium.com/@rahulraks25/migrating-asynctask-to-kotlin-coroutines-e93e9f45d995
Github: https://github.com/ladrahul25/CoroutineAsyncTask