title: How to inject viewModel in BaseFragment using Koin
body: <p>I have created an abstract <code>BaseFragment</code> class which will be extended by other concrete <code>Fragment</code> classes. I want to inject <code>ViewModel</code> in my <code>BaseFragment</code> using <code>Koin</code>. Here is my BaseFragment:</p>
  
  <pre><code>abstract class BaseFragment&lt;out VM : BaseViewModel, DB : ViewDataBinding&gt;(private val mViewModelClass: Class&lt;VM&gt;) : Fragment() {
  
      val viewModel: VM by viewModel()
  
      open lateinit var binding: DB
  
      fun init(inflater: LayoutInflater, container: ViewGroup) {
          binding = DataBindingUtil.inflate(inflater, getLayoutRes(), container, false)
      }
  
      open fun init() {}
      @LayoutRes
      abstract fun getLayoutRes(): Int
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                                savedInstanceState: Bundle?): View {
          init(inflater, container!!)
          init()
          super.onCreateView(inflater, container, savedInstanceState)
          return binding.root
      }
  
      open fun refresh() {}
  } 
  </code></pre>
  
  <p>But I am not able to do so. I am using <code>2.0.1</code> version of Koin.</p>