https://kotlinlang.org logo
#compose
Title
# compose
v

Vlad

11/13/2023, 12:02 PM
I am returning to the forever topic in android community: one time events withing MVVM (User events, Ui Events). I run through community posts and chats and see that there are currently 2 main paths: 1. Recommended by [G] team which is to reduce the events to the state. (And deal with resetting the state after the consumption to ensure it won't run again). 2. Using different to state observable for events/effects. Aka private val _uiEffects = MutableSharedFlow<UiEffect>(extraBufferCapacity = 100) or channels, doesn't matter. 3. Neither (you might add what you are doing in the comments if you wish) I am not triggering another round of the discussion but curious what you guys do lately. So react please with 1️⃣ 2️⃣ 3️⃣
3️⃣ 2
1️⃣ 7
m

Marcin Wisniowski

11/13/2023, 12:06 PM
Event class that’s part of the state, with a getter that clears it. So like option 1, except no need for manual resetting.
1
z

Zoltan Demant

11/13/2023, 1:39 PM
Imo,
#1
works great but it also introduces a bunch of boilerplate for each viewmodel where you do it; I heavily dislike that part but have not found a better option that just works in the long run as well.
2
2 Views