Skip to content

Commit

Permalink
Fixed a Kotlin code sample to invoke the superclass constructor when …
Browse files Browse the repository at this point in the history
…inheriting from ViewModel.

PiperOrigin-RevId: 609140050
  • Loading branch information
yorickhenning authored and Dagger Team committed Feb 21, 2024
1 parent 6411c60 commit 68e0a97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hilt/view-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class FooViewModel extends ViewModel {
class FooViewModel @Inject constructor(
val handle: SavedStateHandle,
val foo: Foo
) : ViewModel
) : ViewModel()
```
{: .c-codeselector__code .c-codeselector__code_kotlin }

Expand Down Expand Up @@ -160,7 +160,7 @@ class MoviePosterFetcher @Inject constructor(
class MovieViewModel @Inject constructor(
val detailFetcher: MovieDetailFetcher,
val posterFetcher: MoviePosterFetcher
) : ViewModel {
) : ViewModel() {
init {
// Both detailFetcher and posterFetcher will contain the same instance of
// the MovieRepository.
Expand Down

0 comments on commit 68e0a97

Please sign in to comment.