May 5, 2020
Fragment & ViewModel
Fragment создает/подключается к ViewModel через Provider’а, используя Factory:
class SleepTrackerFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { ... val sleepTrackerViewModel = ViewModelProviders.of( this, viewModelFactory).get(SleepTrackerViewModel::class.java) ...