Lukasz Burcon
09/13/2021, 12:44 PMderivedStateOf is misleading, and it that SideEffect should be declared in remember using no keys to really benefit from its caching mechanism.
Here’s a documentation using keys with remember with derivedStateOf:
<https://developer.android.com/jetpack/compose/side-effects#derivedstateof>
And here’s a documentation that doesn’t use keys in remembers:
<https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#derivedStateOf(kotlin.Function0)>
Any thoughts on that?Zach Klippenstein (he/him) [MOD]
09/13/2021, 7:13 PMSideEffectLukasz Burcon
09/13/2021, 7:48 PMZach Klippenstein (he/him) [MOD]
09/14/2021, 2:26 PMhighPriorityKeywords into a state (eg using rememberUpdatedState) and then get rid of the remember keys around derivedStateOf?Lukasz Burcon
09/14/2021, 2:28 PMderivedStateOf knows when to reevaluate itself. That would make perfect sense for meZach Klippenstein (he/him) [MOD]
09/14/2021, 2:39 PMhighPriorityKeywords argument into a state otherwise the derivedStateOf lambda would just capture the initial value and never update if the caller passed a different list inZach Klippenstein (he/him) [MOD]
09/14/2021, 2:40 PMtodoTasks as a key shouldn’t actually change behavior in this case, I believe, because that list is always the same object. So even if the contents of the list change, it shouldn’t invalidate the remember, and the derivedStateOf will handle the update itself as you’d probably want.Zach Klippenstein (he/him) [MOD]
09/14/2021, 2:43 PMhighPriorityKeywords in a state and got rid of the keys, it wouldn’t save you anything when highPriorityKeywords changed since the only for that to happen would mean that the function was already being reexecuted.