Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Hilt ViewModels and Dependency Injection

CodingWithMitch via YouTube

Overview

Learn how to implement dependency injection into ViewModels using Hilt in Android development. Explore the advantages of constructor injection over field injection and discover how Hilt simplifies ViewModel instantiation in Fragments and Activities. Master the "by viewModels()" method for maintaining ViewModel instances in Fragments and the "by activityViewModels()" method for sharing ViewModels across multiple Fragments with a common host Activity. Follow along with practical examples and gain insights into efficient package structuring, ViewModel building, and dependency injection techniques for Android applications.

Syllabus

Introduction
Dependency Injection
Package Structure
Building the ViewModel
Using ViewModelInject
Using Dependency Injection
Sharing ViewModels
Outro

Taught by

CodingWithMitch

Reviews

Start your review of Hilt ViewModels and Dependency Injection

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.