grandstaish
06/12/2020, 8:20 PMcollectAsState but it is resulting in an infinite composition loop. When I call collectAsState it seems to just get the latest state and then trigger a recomposition, and then repeats that loop forever. Does anyone know what I am missing? I’m new to both technologies so it’s probably something really obvious!grandstaish
06/12/2020, 8:21 PM@Composable
fun App(component: AppComponent) {
  val authRepository = component.authRepository()
  when (val authState = authRepository.state().collectAsState().value) {
    is AuthState.Authorized -> {
      // show login flow
    }
    is AuthState.Authenticated -> {
      // show user flow
    }
  }
}Luca
06/12/2020, 8:22 PMcomponent.authRepository() make a new instance everytime?grandstaish
06/12/2020, 8:22 PMLuca
06/12/2020, 8:24 PMgrandstaish
06/12/2020, 8:25 PMLuca
06/12/2020, 8:25 PMLuca
06/12/2020, 8:25 PMgrandstaish
06/12/2020, 8:28 PMTash
06/12/2020, 8:30 PMgrandstaish
06/12/2020, 8:31 PMZach Klippenstein (he/him) [MOD]
06/12/2020, 9:09 PMTash
06/12/2020, 9:12 PMTash
06/12/2020, 9:12 PMAdam Powell
06/12/2020, 9:23 PMauthRepository.state() does not change across calls, it won't resubscribe, it'll keep the existing subscription across recompositionsAdam Powell
06/12/2020, 9:24 PMremember with your original inputs:
val state = remember(authRepository) { authRepository.state() }Adam Powell
06/12/2020, 9:24 PM.state() call if authRepository changes