Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is the difference? #4

Open
periva101 opened this issue Oct 9, 2022 · 2 comments
Open

what is the difference? #4

periva101 opened this issue Oct 9, 2022 · 2 comments

Comments

@periva101
Copy link

Hello again,
I almost study each GitHub KMM sample your's is the best.
I have a question if you plz.

private val _event: MutableSharedFlow<Event> = MutableSharedFlow()
  val event = _event.asSharedFlow()

  private val _effect: Channel<Effect> = Channel()
  val effect = _effect.receiveAsFlow()

what is the clear difference between effects and events?
and why events are MutableSharedFlow where _effect is Channel

@daniaviladomingo
Copy link
Owner

Hi!

Thank you so much!!

Event are UI action to ViewModel. UI -> ViewModel
Effect are single shot event from ViewModel to UI (don't have state) like show toast, show snack bar, show dialog or navigation action.

MVI pattern is based in this great article: https://proandroiddev.com/mvi-architecture-with-kotlin-flows-and-channels-d36820b2028d

@ghost
Copy link

ghost commented Oct 10, 2022

Thank you so much!
Thank you so much!!
Thank you so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants