https://kotlinlang.org logo
#android
Title
# android
f

Fabio Berta

03/15/2023, 2:06 PM
Hi, I have certain functionality that is used by multiple view models. I'd like to centralise this into a separate object and use it in the view models through delegation. However, to perform its actions that object needs a coroutine scope -> viewModelScope. Is there a clean way to provide this to the delegate while still benefitting from the
by
syntax? All solutions I found so far rely on runtime exceptions which I would like to avoid. Any ideas?
Or maybe my approach is conceptually wrong 🤔
3 Views