lateinit var binding: FragmentRegisterEmailBinding @Inject lateinit var viewModel: RegisterEmailViewModel override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_register_email, container, false) binding = FragmentRegisterEmailBinding.bind(view).also { fragmentRegisterEmailBinding -> fragmentRegisterEmailBinding.viewmodel= viewModel } return view } override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) viewModel.also { viewModel -> viewModel.repository.setViewModel(viewModel as RegisterEmailDataSource.ViewModel) viewModel.onBackPressed.observe(this, Observer { onBackPressed() }) } } override fun onAttach(context: Context?) { super.onAttach(context) component.inject(this) lifecycle.addObserver(viewModel as LifecycleObserver) } }