I have a variable defined like ``` val faceCond...
# compose
e
I have a variable defined like
Copy code
val faceConditionsChecker by remember {
        mutableStateOf(
            FaceConditionsChecker {
                faceFrameRect
            }
        )
    }
Where
faceFrameRect
is a parameter of the composable function. I pass it via lambda to the class
FaceConditionsChecker
using it as
val frameProvider: () -> RectF
. Will the value of faceFrameRect when the lambda is called always correspond to the actual value of the parameter
faceFrameRect
? If not how could I recreate FaceConditionsChecker on parameter change?
m
remember
has no way to know that your function recomposed with a different
faceFrameRect
value to re-execute the lambda body. to fix this add
faceFrameRect
as a key to remember
☝🏻 1
z
But then I would ask if you really need to have that in a state object, or even remembered, at all
e
Thanks, guys! I really missed the
key
parameter or the
remember
. And it really makes sense to refactor this, because actually FaceConditionsChecker is stateless and I can replace it by a static function.
👍🏻 1