I am returning to the forever topic in android com...
# compose
v
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️⃣
2️⃣ 1
3️⃣ 2
1️⃣ 7
m
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
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