https://kotlinlang.org logo
#compose
Title
# compose
c

Chris Fillmore

04/19/2022, 7:08 PM
Can someone advise on using
MultiplePermissionsState
as the
key
in a LaunchedEffect?
I have code roughly like
Copy code
val cameraPermissionState = rememberMultiplePermissionsState(
  permissions = listOf(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO),
)

LaunchedEffect(cameraPermissionState) {
  if (!cameraPermissionState.permissionRequested) {
    cameraPermissionState.launchMultiplePermissionRequest()
  }
  // The below is a just a lambda callback to the parent, so it can e.g. open the camera on permission granted
  onPermissionsUpdated(cameraPermissionState)
}
But looking at
internal class MutableMultiplePermissionsState
, I don’t think I should be using this as a
key
, since it doesn’t override
equals()
(correct me if this reasoning is wrong)
Should I be key-ing specific effects on the properties of
MultiplePermissionsState
instead?
I had hoped to just pass MultiplePermissionsState back on to the parent directly on any change
Thanks for any feedback!
8 Views