Youssef Shoaib [MOD]
04/24/2024, 10:26 PMremember. It seems that currentComposer.cache does this, but with a big disclaimer and no-no all over it. Is there any supported way to do this? Would it be okay to do something like this instead:
private object Flip {
override fun equals(other: Any?): Boolean {
// Not equal to itself
return Keep == other
}
}
private data object Keep
remember(if (shouldUpdate) Flip else Keep) { ... }
This works, but I'm concerned that it might break in the futureChris Fillmore
04/24/2024, 10:33 PMStylianos Gakis
04/24/2024, 10:39 PMneverEqualPolicy as the SnapshotMutationPolicy to apply to a mutableState which will consider itself not equal to the previous value if you set the same value to it again.
Not sure if that’s what you want here, but what you say kinda makes me think about it.Alex Vanyo
04/24/2024, 10:52 PMequals, and almost immediately started getting confused by behavior.Youssef Shoaib [MOD]
04/24/2024, 10:54 PMSnapshopMutationPolicy yes.
I didn't want to keep an Int around because If I'm keeping a mutable object anyways then I might aswell just:
data class State<S>(var state: S?)
remember { State<Blah>(null) }.apply { if(shouldUpdate || state == null) state = ... }Alex Vanyo
04/24/2024, 10:55 PMshouldUpdate in there feels suspicious, what is driving the value of shouldUpdate?Youssef Shoaib [MOD]
04/24/2024, 11:45 PMisEmpty call on a piece of outside state. Both of these I can't really see being able to easily transform into the form that remember wants.