Ahmed Ibrahim
03/14/2020, 10:56 AMEither.applicative().map(sectionsResult, sectionsResult.map(this::gatherAllSaleIds)) {
(sections: List<SalesSectionsQuery.SalesSection>, saleIds: List<SaleId>) ->
// This is a suspend function remoteSalesDataSource.sales(AFFILIATE, saleIds)
}
Ahmed Ibrahim
03/14/2020, 11:00 AMaballano
03/14/2020, 12:31 PMaballano
03/14/2020, 1:17 PMEither.applicative<String>().map(sectionsResult, sectionsResult.map(::gatherAllSaleIds), ::identity)
.flatMap { Either.catch { getSales(AFFILIATE, it.b) } }
So, the thing is Either is not really fancy when dealing with effects as suspend functions because is not really meant to that. For that we normally use IO which is very powerful in that matteraballano
03/14/2020, 1:18 PMAhmed Ibrahim
03/14/2020, 1:18 PMaballano
03/14/2020, 1:25 PMaballano
03/14/2020, 1:25 PMaballano
03/14/2020, 1:25 PMEither.fx {
val ids = sectionsResult.map(::gatherAllSaleIds)
!Either.catch { getSales(AFFILIATE, ids) }
}