Hello everyone, Is there a problem with this code...
# orbit-mvi
e
Hello everyone, Is there a problem with this code that can cause the state not to be modified? The logs display very well when there is an error or when the operation is successful but at the view level the state has always the default value
Copy code
private fun Flow<Result<List<Lottiefile>>>.fetchData() = intent(registerIdling = false) {
    collect { result ->
      when(result) {
        is Result.Error -> {
          Timber.e(result.toString())
          val errorMessage = result.exception.localizedMessage ?: "Unknown Error"
          reduce { state.copy(isLoading = false) }
          postSideEffect(ExploreEffect.ShowErrorMessage(errorMessage))
        }
        Result.Loading -> {
          Timber.e(result.toString())
          reduce { state.copy(isLoading = true) }
        }
        is Result.Success -> {
          Timber.e(result.toString())
          reduce { state.copy(files = result.data, isLoading = false) }
        }
      }
    }
  }
The state is collected like that
Copy code
val state by viewModel.container.stateFlow.collectAsState()
m
@Eric Ampire [MOD] I have a hunch - how are you overriding the
container
field?
o
also, I’ve found kotlin still doesn’t play nice with
Flow<Result>
-> try removing the Result from the type
e
Here the code @Mikolaj Leszczynski
o
@Eric Ampire [MOD] the container you use for state is not the same instance of container used for
intent{}
-> remove get() in favour of property initializer
☝️ 1
e
Okay thanks, it's working