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?SnapshotStateList<MutableState>
for list of mutable itemsAdam Powell
10/11/2020, 2:15 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 PMEditClickTrackScreenState
?EditClickTrackScreenState
Vsevolod 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 PMAdam Powell
10/11/2020, 4:40 PMonCommit
block here entirelyMutableState
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 purposeanimatedFloat
. 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 necessary@Composable animate
APIs also encourage this; we're looking into that as wellMutableState<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) }
}
Vsevolod Ganin
10/11/2020, 6:16 PMAdam Powell
10/11/2020, 7:52 PM