~captainepoch/husky

1c9021346e976f8f139aa10f7f2541581dd9bc2b — Adolfo Santiago a month ago b37bb78
Create RegisteredViewModel for ViewModels with services
A husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/RegisteredViewModel.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/RegisteredViewModel.kt +18 -0
@@ 0,0 1,18 @@
package com.keylesspalace.tusky.core.ui.viewmodel

import com.zhuinden.simplestack.ScopedServices
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

abstract class RegisteredViewModel : BaseViewModel(), ScopedServices.Registered {

    private val compositeDisposable = CompositeDisposable()

    override fun onServiceUnregistered() {
        compositeDisposable.clear()
    }

    fun addDisposable(disposable: Disposable) {
        compositeDisposable.add(disposable)
    }
}