prof18/RSS-Parser

Why is the example code adding a job to the coroutine scope?

mddrill opened this issue · 1 comments

In the viewmodel in the kotlin example, I see this code:

private val viewModelJob = Job()
private val coroutineScope = CoroutineScope(Dispatchers.Main + viewModelJob)

I'm trying to figure out why that viewModelJob is needed.

I see you're canceling the job when the viewmodel lifecycle ends. Will memory leaks happen if I use this library and forget to do that? If so, it might be nice to incorporate that behavior into the library somehow.

The library is not aware of the android lifecycle events, so you need to clear the resources to avoid any possible leak.
Instead of the custom scope, you can use the viewModelScope provided by the viewmodel-ktx.
I've just updated the sample with that -> 2ae7c18