aleyn97 / MVVMLin

一个基于MVVM用Kotlin+Retrofit+协程+Databinding+LiveData来封装的快速开发框架

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BaseViewModel 为什么要实现LifecycleObserver接口,具体干什么用的

sweet2o09 opened this issue · comments

/**
 *   @auther : Aleyn
 *   time   : 2019/11/01
 */
open class BaseViewModel : AndroidViewModel(Utils.getApp()), LifecycleObserver
commented

为了能知道Activity生命周期,比如有一些依赖Activity生命周期的操作,就可以用@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) 等这些注解 直接 写在 ViewModel中

原来如此,我是看你的这个框架里面没有相关的注解所以有点困惑 @AleynP