Hello guys ```@Composable fun SomeComposable(windo...
# compose
b
Hello guys
Copy code
@Composable
fun SomeComposable(windowSize: WindowSize) {
    Column(
        modifier = remember {
            when (windowSize.widthSize) {
                COMPACT -> Modifier.size(300.dp)
                MEDIUM -> Modifier.size(600.dp)
                EXPANDED -> Modifier.size(900.dp)
            }
        }
    ) {

    }
}
Is wrapping this under remember actually worth it? Benefit of using remember is during recomposition it doesn't needs to calculate the section. But just feels weird adding remember to that. Is this okay?
windowSize
changes only during configuration change. i.e Entire tree will be provided for composition)
h
The
Column
(as it is an inline function) will be recomposed whenever
SomeComposable
recomposes too. Even if the
windowSize
is stable, it will trigger a recomposition when it changes (the
equal
method will be different). If the
windowSize
were not stable (I don’t know now), the
SomeComposable
would be recomposed every time. Therefore I think having the
remember
function is useless.
b
windowSize is stable and will not be changed. (If at all changed then whole tree be in for composition. Not recomposition) Now, In real apps, if some other param changes and this composable is recomposed. In that case, it will be useful, right? My question, how much is it useful by weighing the cost of remember function
h
From what you wrote I would say the
remember
function is not useful and maybe adds a slight overhead.
b
Yeah I too feel the same but not sure of that. Thanks.