Hi! I'm reading <this> article re: disposables (no...
# android
i
Hi! I'm reading this article re: disposables (not an rx specific question, so asking here). The snippet in question:
Copy code
abstract class DisposingViewModel : ViewModel() {
    private val compositeDisposable = CompositeDisposable()
    fun addDisposable(disposable: Disposable) {
        compositeDisposable.add(disposable)
    }
    override fun onCleared() {
        compositeDisposable.clear()
    }
}
(the idea is having view models extending
DisposingViewModel
so they don't have to repeat this boilerplate) Author says then
If you are against the idea of inheritance being used in this way (you aren’t alone) then it’s worth noting that creating a solution for this using class delegation in Kotlin is not much more work.
I'm not very familiar with (idiomatic) delegation. I read that I've to add
by
to the class, but failing to see how to apply that to this case