package com.develop.common.ui

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.develop.base.mvvm.BaseViewModel
import org.greenrobot.eventbus.EventBus


/**
 * 带业务逻辑的基类，带view model
 */
abstract class CommonBVMActivity<VB : ViewBinding, VM : BaseViewModel> :
    CommonBindingActivity<VB>() {
    protected lateinit var viewModel: VM

    abstract fun createViewModel(): VM

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewModel = createViewModel()
        lifecycle.addObserver(viewModel)
    }

    override fun onDestroy() {
        super.onDestroy()
        lifecycle.removeObserver(viewModel)
    }



}