Skip to content

saifi369/PassingStatesWithSealedClasses

Repository files navigation

Passing UIState from ViewModel to Activity with Kotlin Sealed Classes

This project is used for tutorials on U4Universe Youtube channel.

Introduction

As our android app uses MVVM architecture, often times we need to send Commands to our View(Activity) from ViewModel.

We can do this using kotlin enums but there is a limitation with enums. We cannot pass any custom data to View with enums.

Kotlin provide another solution for this ---> SealedClasses

We'll learn

  • Create UIState with Sealed Classes
  • Send States from ViewModel to Activity
  • Update the View according to Ui States

Contact Info

You can contact me if you have any problem related to code or video.

Instagram

Facebook

Gmail chsaif369@gmail.com

Note

This repository may contain multiple branches. Each video uses its own branch, so make sure to check the branch used in the video and then select that branch from branch list.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Releases

No releases published

Packages

No packages published

Languages