Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for AAC Lifecycle 2.5.0 #615

Open
kenyee opened this issue Dec 1, 2022 · 0 comments
Open

update for AAC Lifecycle 2.5.0 #615

kenyee opened this issue Dec 1, 2022 · 0 comments

Comments

@kenyee
Copy link

kenyee commented Dec 1, 2022

The AndroidX ViewModel library offers a viewModelScope extension function to provide an auto-cancelled CoroutineScope, but again, this CoroutineScope is hard-coded and uses Dispatchers.Main. This limitation needn't exist.

This is no longer true w/ Lifecycle 2.5.0+:
https://developer.android.com/jetpack/androidx/releases/lifecycle#2.5.0

"addCloseable() API and a new constructor overload that allow you to add one or more Closeable objects to the ViewModel that will be closed when the ViewModel is cleared without requiring any manual work in onCleared()."
So you can pass in a Closable coroutinescope to a viewmodel's constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant