tad
07/16/2021, 12:37 AMFlow.collectAsState
for Compose UI state)Adam Powell
07/16/2021, 1:04 AMinitial =
value for collectAsState
vs. constructing a new one to pass that gets discarded 🙂.copy
calls will start standing out next to other code that was simplified in the migration, and tools like arrow lenses or snapshot mutable state start to look compelling for addressing some of thatcollectAsState
usage that nudge away from it are more around things that muddle the distinction between state and events, or that jump through a lot of hoops for creating different forms of derived state using `StateFlow`stad
07/16/2021, 3:08 AMdimsuz
07/16/2021, 9:48 AMppvi
07/16/2021, 12:52 PMColton Idle
07/16/2021, 1:10 PMppvi
07/16/2021, 1:25 PMMutableLiveData
or MutableStateFlow
but most exposed state comes from another Flow anyway so they're the result of a combine
, flatMapLatest
, etc. Are backing properties that common and annoying in your codebase that you want a completely different pattern? Could you be abusing the mutable data holders?Adam Powell
07/16/2021, 1:29 PMColton Idle
07/16/2021, 1:38 PMCould you be abusing the mutable data holders?Most likely. Adam Powell once I'm back at my machine I will try to send something across. I think it's mostly due to different libraries that we've used in order to do this. We used to use the SingleLiveEvent from that article from Jose that was written a while back, and ever since we've been bouncing around different libraries.
ppvi
07/16/2021, 1:39 PMAdam Powell
07/16/2021, 2:57 PMppvi
07/16/2021, 3:08 PMColton Idle
07/16/2021, 3:25 PMAdam Powell
07/16/2021, 3:46 PMppvi
07/16/2021, 4:03 PMdimsuz
07/16/2021, 4:14 PMAdam Powell
07/16/2021, 5:44 PMButton
composable is the consumer by way of the onClick
function passed as a parameter, and it outlives the Button
itself (the event producer)Colton Idle
07/16/2021, 5:46 PMAdam Powell
07/16/2021, 7:10 PMView.OnClickListener#onClick
are 🙂Colton Idle
07/16/2021, 7:15 PMAdam Powell
07/16/2021, 7:15 PMColton Idle
07/16/2021, 7:18 PMtad
07/16/2021, 7:19 PMAdam Powell
07/16/2021, 7:20 PMColton Idle
07/16/2021, 7:24 PMAdam Powell
07/16/2021, 7:29 PMColton Idle
07/16/2021, 7:31 PMAdam Powell
07/16/2021, 7:32 PMColton Idle
07/16/2021, 7:34 PMAdam Powell
07/16/2021, 7:53 PMif (vm.validate(info)) { navigator.navigateTo(next) }
is still valid code but doesn't have to live in the vm itself, it can live in a place where both vm
and navigator
are in scopeColton Idle
07/16/2021, 8:00 PMAdam Powell
07/16/2021, 8:02 PMnow I have business logic in my fragment thendon't you have this where you wire up click handlers already?
Colton Idle
07/16/2021, 8:06 PM