Andy Himberger
01/31/2022, 9:05 PMZach Klippenstein (he/him) [MOD]
02/01/2022, 2:59 AMChuck Jazdzewski [G]
02/01/2022, 3:03 AMAndy Himberger
02/01/2022, 4:20 AMZach Klippenstein (he/him) [MOD]
02/01/2022, 1:53 PMit seemed like static is what we would want if its supposed to have better performance in situations where updating the value should recompose everythingNot really. Dynamic locals will also cause everything that reads them to recompose. Static locals are meant for times when it's expected that the value will never change (eg values that are by nature tied to the lifetime of the composition itself, such as the hosting View), because when it does change it recomposes literally everything underneath it. In your case, where it's conceivable that the layout mode could change to react to config changes, and especially since you're only reading the value from a few places, it really doesn't make sense to use static because the small overhead of doing a little state tracking is probably way cheaper than recomposing basically every function in your app when there's a change that the vast majority of them don't care about.
Alex Vanyo
02/01/2022, 5:45 PMAndy Himberger
02/02/2022, 4:38 AM