Kulwinder Singh
08/24/2019, 9:05 AMSingleLiveEvent but previously i had seen some type of Event (don't know exactly what it was called) class. i have seen that class somewhere in google architecture samples or in I/O talk but now i'm unable to find that, can you guys please let me know if SingleLiveEvent is best for one time event or is android team provided some other solutions ?Dominaezzz
08/24/2019, 10:31 AMLiveData with a flag for single events.rkeazor
08/24/2019, 1:48 PMAdam Powell
08/24/2019, 2:10 PMAdam Powell
08/24/2019, 2:12 PMrkeazor
08/24/2019, 2:12 PMAdam Powell
08/24/2019, 2:13 PMrkeazor
08/24/2019, 2:18 PMrkeazor
08/24/2019, 2:20 PMAdam Powell
08/24/2019, 2:20 PMrkeazor
08/24/2019, 2:21 PMrkeazor
08/24/2019, 2:21 PMAdam Powell
08/24/2019, 2:21 PMrkeazor
08/24/2019, 2:22 PMAdam Powell
08/24/2019, 2:22 PMAdam Powell
08/24/2019, 2:23 PMAdam Powell
08/24/2019, 2:23 PMAdam Powell
08/24/2019, 2:24 PMAdam Powell
08/24/2019, 2:25 PMAdam Powell
08/24/2019, 2:26 PMrkeazor
08/24/2019, 2:26 PMdewildte
08/24/2019, 2:27 PMAdam Powell
08/24/2019, 2:27 PMAdam Powell
08/24/2019, 2:28 PM.getValue() agrees with the value seen by observersdewildte
08/24/2019, 2:28 PMAdam Powell
08/24/2019, 2:28 PM.getValue() would return something different, active observers are told about it.Adam Powell
08/24/2019, 2:29 PMAdam Powell
08/24/2019, 2:29 PMdewildte
08/24/2019, 2:29 PMAdam Powell
08/24/2019, 2:30 PMrkeazor
08/24/2019, 2:30 PMrkeazor
08/24/2019, 2:30 PMAdam Powell
08/24/2019, 2:30 PMdewildte
08/24/2019, 2:31 PMrkeazor
08/24/2019, 2:32 PMAdam Powell
08/24/2019, 2:32 PMAdam Powell
08/24/2019, 2:33 PMAdam Powell
08/24/2019, 2:34 PMrkeazor
08/24/2019, 2:38 PMrkeazor
08/24/2019, 2:38 PMrkeazor
08/24/2019, 2:39 PMAdam Powell
08/24/2019, 2:39 PMAdam Powell
08/24/2019, 2:39 PMrkeazor
08/24/2019, 2:40 PMAdam Powell
08/24/2019, 2:42 PMprivate val _events = MutableLiveData<Action>()
val events: LiveData<Action> get() = _events to prevent outside things from writing into it, since you've provided the ViewModel functions to write alreadyAdam Powell
08/24/2019, 2:43 PMprivate val _events = BroadcastChannel<Action>()
val events = _events.asFlow()rkeazor
08/24/2019, 2:44 PMrkeazor
08/24/2019, 2:45 PMAdam Powell
08/24/2019, 2:46 PMobserve call (to which you forgot to specify a lifecycle to observe in ๐ ) and do appropriateScope.launch {
viewModel.events.collect {
when (it) { ...Adam Powell
08/24/2019, 2:48 PM.offer - you can decide what your backpressure behavior should be via the BroadcastChannel constructor - default is drop if no one is listening, first wins if you use 1 as a buffer size, last wins if you use Channel.CONFLATEDAdam Powell
08/24/2019, 2:49 PMEvent<T> holdersAdam Powell
08/24/2019, 2:51 PMrkeazor
08/24/2019, 2:56 PMrkeazor
08/24/2019, 2:58 PMrkeazor
08/24/2019, 2:58 PMAdam Powell
08/24/2019, 2:59 PMrkeazor
08/24/2019, 3:00 PMAdam Powell
08/24/2019, 3:04 PMAdam Powell
08/24/2019, 3:05 PMrkeazor
08/24/2019, 3:07 PMAdam Powell
08/24/2019, 3:09 PMrkeazor
08/24/2019, 3:10 PMrkeazor
08/24/2019, 3:10 PMwasyl
08/24/2019, 9:49 PMAdam Powell
08/24/2019, 11:34 PMAdam Powell
08/24/2019, 11:36 PMAdam Powell
08/24/2019, 11:39 PMAdam Powell
08/24/2019, 11:40 PMSingleLiveEvent and LiveData<Event<T>> are workarounds to avoid solving those underlying problems that will continue to be a source of confusion and bugs.Kulwinder Singh
08/25/2019, 4:52 AMSingleLiveEvent vs LiveData<Event<T>> vs Flow ?giso
08/25/2019, 6:47 AMrkeazor
08/25/2019, 9:55 AMrkeazor
08/25/2019, 9:57 AMrkeazor
08/25/2019, 9:58 AMrkeazor
08/25/2019, 9:59 AMKulwinder Singh
08/25/2019, 10:20 AMFlow inside android, i have very good experience in coroutines but unable to understand Flow, is there any blog or something where use cases of Flow inside android app are shownrkeazor
08/25/2019, 1:22 PMrkeazor
08/25/2019, 1:23 PMrkeazor
08/25/2019, 1:30 PMrkeazor
08/25/2019, 5:05 PMKulwinder Singh
08/26/2019, 5:16 AMAdam Powell
08/26/2019, 2:07 PMAdam Powell
08/26/2019, 2:09 PMonClear. The source of truth must be somewhere that outlives ViewModels.Adam Powell
08/26/2019, 2:12 PMdewildte
08/27/2019, 2:58 PMFlow<Event>.dewildte
08/27/2019, 3:00 PMghedeon
09/09/2019, 8:59 PMEvent (currently used in google examples) is bad, SingleLiveData is even worse and Flow is not lifecycle aware. Pick your poison.rkeazor
09/09/2019, 10:07 PMKulwinder Singh
09/10/2019, 2:41 AMSingleLiveData?, because i'm using this in my most of projects.ghedeon
09/10/2019, 6:23 AMelizarov
09/10/2019, 12:27 PMwasyl
09/10/2019, 12:52 PMLiveData handles this for us, while RxJava/Flow doesnโt. I donโt think thereโs any claim that Flow lacks something, it just doesnโt integrate with Android lifecycle without some extra work, same as RxJavaelizarov
09/10/2019, 12:53 PMrkeazor
09/10/2019, 1:48 PMdewildte
09/10/2019, 2:24 PMSTARTED state it should not be issuing updates to itโs UI.
While itโs not in at least the STARTED state and collecting from a Flow itโs collection coroutine should suspend.
I am not sure if it does that as I have not looked but I think that is the concern here.dewildte
09/10/2019, 2:27 PMdewildte
09/10/2019, 2:28 PMdewildte
09/10/2019, 2:33 PMrkeazor
09/10/2019, 2:35 PMdewildte
09/10/2019, 2:40 PM