While working with flow I'm having a type mismatch with the following code:
Copy code
homeRepository
.requestStuff()
.map { stuff -> HomeState.Success(stuff) }
.catch {
emit(HomeState.Error.Unknown(it)) <- type mismatch as FlowCollector is waiting for the HomeState.Success type
}
By adding
.filterIsInstance<HomeState>()
before
.catch {...}
it works, but I'm wondering if there is a better way 🤔
Thanks!
a
Adam Powell
05/27/2021, 3:23 PM
.map { stuff -> HomeState.Success(stuff) as HomeState }