saifi369 / PassingStatesWithSealedClasses

Passing UIState from viewmodel to activity using kotlin sealed classes

Home Page:https://www.youtube.com/u4universe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Passing UIState from viewmodel to activity using kotlin sealed classes

https://www.youtube.com/u4universe


Languages

Language:Kotlin 100.0%