Open EmmanuelMess opened 3 years ago
We seem to have a better solution now https://developer.android.com/topic/libraries/architecture/coroutines
So we use viewmodel like we normally would, and then something like viewModelScope.launch{}
to launch a computation in that viewmodel. It'll be bound to it, so when viewmodel clears, the coroutine would be cancelled as well. We won't have to maintain it's state.
We seem to have a better solution now developer.android.com/topic/libraries/architecture/coroutines
So we use viewmodel like we normally would, and then something like
viewModelScope.launch{}
to launch a computation in that viewmodel. It'll be bound to it, so when viewmodel clears, the coroutine would be cancelled as well. We won't have to maintain it's state.
I thought this as a step towards that.
We seem to have a better solution now developer.android.com/topic/libraries/architecture/coroutines
So we use viewmodel like we normally would, and then something like
viewModelScope.launch{}
to launch a computation in that viewmodel. It'll be bound to it, so when viewmodel clears, the coroutine would be cancelled as well. We won't have to maintain it's state.
How does this deal with Context leaks?
public class ReadFileTask extends AsyncTask<Void, Void, ReturnedValueOnReadFile> {
topublic class ReadFileTask implements Callable<ReturnedValueOnReadFile> {
and used as