Vsevolod Ganin
10/11/2020, 2:09 PMonCommit with input of some SnapshotMutableState doesn’t trigger its lambda when value changes. onCommit with SnapshotMutableState::value does. That’s more likely because SnapshotMutableState doesn’t implement and delegate equals to its value. Is this intentional behavior?Vsevolod Ganin
10/11/2020, 2:11 PMSnapshotStateList<MutableState> for list of mutable itemsAdam Powell
10/11/2020, 2:15 PMAdam Powell
10/11/2020, 2:16 PMonCommit code where you are trying to use it like this? We're reworking some of these runtime effect functions to be more use case driven and the data point would be usefulVsevolod Ganin
10/11/2020, 2:36 PMAdam Powell
10/11/2020, 4:17 PMAdam Powell
10/11/2020, 4:17 PMEditClickTrackScreenState?Adam Powell
10/11/2020, 4:19 PMEditClickTrackScreenStateVsevolod Ganin
10/11/2020, 4:34 PMAdam Powell
10/11/2020, 4:38 PMdispatch is meant to signal the calling code to generate a new state?Vsevolod Ganin
10/11/2020, 4:39 PMVsevolod Ganin
10/11/2020, 4:40 PMAdam Powell
10/11/2020, 4:40 PMAdam Powell
10/11/2020, 4:40 PMonCommit block here entirelyAdam Powell
10/11/2020, 4:42 PMMutableState objects to EditClickTrackScreenContent, pass value/callback pairs, or even some sort of interface that removes the desire to use onCommit as a state-observing dispatch trampolineVsevolod Ganin
10/11/2020, 4:57 PMPublishSubject really. In that way I could pass only one argument for every piece of state that mutates separately instead of two. So I used MutableState and its elevated observer/observable capabilities only for that purposeVsevolod Ganin
10/11/2020, 5:02 PManimatedFloat. When animation completes, my composable emits a new value computed from some animation offset. This can be considered as synchronization between two sources of truth as wellAdam Powell
10/11/2020, 5:36 PMonCommit(myMutableState.value) thing is emerging as a pretty significant antipattern. It doesn't do what you think it does, for one; you will always get events a frame late to have an effect on the current composition, and it forces recomposition of `onCommit`'s caller when it's not necessaryAdam Powell
10/11/2020, 5:37 PM@Composable animate APIs also encourage this; we're looking into that as wellAdam Powell
10/11/2020, 5:41 PMAdam Powell
10/11/2020, 5:42 PMAdam Powell
10/11/2020, 5:50 PMAdam Powell
10/11/2020, 5:57 PMMutableState<T> you could do something like this, I suppose:
inline fun <T> mutableState(
crossinline get: () -> T,
crossinline set: (T) -> Unit
): MutableState<T> = object : MutableState<T> {
override var value: T
get() = get()
set(value) {
set(value)
}
override fun component1(): T = value
override fun component2(): (T) -> Unit = { set(it) }
}Adam Powell
10/11/2020, 5:57 PMAdam Powell
10/11/2020, 6:00 PMVsevolod Ganin
10/11/2020, 6:16 PMVsevolod Ganin
10/11/2020, 6:20 PMVsevolod Ganin
10/11/2020, 6:28 PMAdam Powell
10/11/2020, 7:52 PM