<@U5UU34LPK> <@U5Q5334GK> I haven't tested, but of...
# announcements
c
@karelpeeters @juan.hurtado I haven't tested, but off of the top of my head I think this should work:
Copy code
abstract class BaseFragment<T : ViewDataBinding, K : ViewModel>
private constructor(
	@LayoutRes private val layoutId: Int,
	private val modelType: Class<K>
) : Fragment() {

	protected lateinit var viewModel: K
	protected lateinit var binding: T

	protected abstract fun bindViewModel(binding: T, viewModel: K)

	override fun onCreateView(
		inflater: LayoutInflater, container: ViewGroup?,
		savedInstanceState: Bundle?
	): View? {
		viewModel = ViewModelProviders.of(this).get(modelType)
		binding = DataBindingUtil.bind(container?.inflate(layoutId))
		bindViewModel(binding, viewModel)
		setHasOptionsMenu(true)
		return binding.root
	}

	companion object {
		operator inline fun <K> invoke(layoutId: Int) =
			BaseFragment(layoutId, K::class.java)
	}
}