package com.develop.common.ui

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.develop.base.mvvm.BaseViewModel

abstract class CommonBVMFragment<T : ViewBinding, VM : BaseViewModel> : CommonBindingFragment<T>() {
    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)
    }
}