louiscad
01/09/2024, 3:09 PMderivedStateOf like for mutableIntStateOf, mutableFloatStateOf, and mutableDoubleStateOf, to avoid autoboxing?shikasd
01/09/2024, 3:13 PMlouiscad
01/09/2024, 3:13 PMderivedStateOf expensive?shikasd
01/09/2024, 3:14 PMlouiscad
01/09/2024, 3:14 PMSnapshotStateObserver directly?shikasd
01/09/2024, 3:18 PMshikasd
01/09/2024, 3:18 PMlouiscad
01/09/2024, 3:19 PMlouiscad
01/09/2024, 3:19 PMderivedStateOf is backed by SnapshotStateObserver, right?louiscad
01/09/2024, 3:19 PMobserveReads on it somewhere?shikasd
01/09/2024, 3:20 PMshikasd
01/09/2024, 3:21 PMlouiscad
01/09/2024, 3:21 PMSnapshotStateObserver wouldn't work the same if you update the final MutableState or Mutable*State, in the change observer lambda, granted that SnapshotStateObserver was started?shikasd
01/09/2024, 3:23 PMshikasd
01/09/2024, 3:23 PMlouiscad
01/09/2024, 3:25 PMSnapshotStateObserver if you don't call observeReads at all, right?louiscad
01/09/2024, 3:25 PMderivedStateOf with just SnapshotStateObservershikasd
01/09/2024, 3:27 PMsnapshotFlow does. SnapshotStateObserver is pretty heavy for observing single state, it is meant to be created once per owner and can create multiple observation contextslouiscad
01/09/2024, 3:32 PMderivedStateOf, and calling this function even if unneeded, which one should I pick, or is there a way to compare the cost calling the function, vs having derivedStateOf unread, vs having derivedStateOf read and running the computation?
fun angle(refAxis: Float, a: Float) = Math.toDegrees(acos(refAxis.toDouble() / a))shikasd
01/09/2024, 3:32 PMshikasd
01/09/2024, 3:33 PMlouiscad
01/09/2024, 3:34 PMlouiscad
01/09/2024, 3:35 PMangle eagerly would be more desirable than using a remembered derivedStateOf, or using SnapshotStateObserver?shikasd
01/09/2024, 3:36 PMshikasd
01/09/2024, 3:53 PMlouiscad
01/09/2024, 3:54 PMshikasd
01/09/2024, 3:55 PMshikasd
01/09/2024, 3:56 PMlouiscad
01/09/2024, 3:56 PMderivedStateOf when recomposing for example blob thinking fastlouiscad
01/09/2024, 3:57 PMshikasd
01/09/2024, 3:58 PMlouiscad
01/09/2024, 3:58 PMlouiscad
01/09/2024, 3:58 PMshikasd
01/09/2024, 3:58 PMstate.value and runtime of the function itselflouiscad
01/09/2024, 3:59 PMstate.value itself has some cost that might be higher than, say, the angle function I showed?ephemient
01/09/2024, 4:09 PMshikasd
01/09/2024, 4:19 PMshikasd
01/09/2024, 4:19 PMlouiscad
01/09/2024, 4:20 PMstate.value can vary?louiscad
01/09/2024, 4:21 PMshikasd
01/09/2024, 4:22 PMlouiscad
01/09/2024, 10:00 PMshikasd
01/10/2024, 6:22 PMlouiscad
01/17/2024, 10:09 AMmap { it % 2 }.distinctUntilChanged().collect { } on a StateFlow<Int> cheaper than having a derivedStateOf doing the same over a MutableIntState or a MutableState<Int>?shikasd
01/17/2024, 12:17 PMLaunchedEffect for the flow, where coroutines also have some cost associated with it.louiscad
01/17/2024, 12:18 PMshikasd
01/17/2024, 12:22 PMFlow here, it's likely to be faster and also more reasonable for non-observable scopes.
The only way to figure out what is faster is to run a benchmark though 😄