Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Base Fragment for dispose observables
/**
* Created by Dinorah Tovar on 8/21/18
* All fragments should extend from this fragment.
*/
open class BaseFragment : Fragment() {
/**
* Keep reference of the active presenter
*/
private var basePresenter: BasePresenter? = null
/**
* Clear disposables once user is no longer on screen.
*/
override fun onDestroy() {
super.onDestroy()
basePresenter?.safeDispose()
basePresenter = null
}
/**
* Set active presenter
*/
fun setPresenter(presenter: BasePresenter?) {
basePresenter = presenter
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment