Skip to content

Concepts involved in application

Devrath edited this page Mar 26, 2022 · 4 revisions

Role of reactive data source

  • The reactive data source is very useful in keeping the code decoupled
  • We can keep the data in the view model as reactive and make it such a way that it is being observed in the view layer(activity/fragment)
  • This way we can prevent memory leaks
  • A memory leak happens when the fragment is destroyed and the reference is kept in the view model

Usage of the channel in the view-model to show a one-time message

  • We use a methodology where we keep a channel in the view model we make it private and such a way that user won't be able to add values to the channel
  • By converting the channel to flow and making it public user can observe the value in the fragment and not add values in the fragment.

Using stateIn

Clone this wiki locally