https://kotlinlang.org logo
Title
a

Ahmed Ibrahim

07/23/2020, 11:18 AM
Any idea why I didn't get a compile error there? The
fetchSaleWithPhotosById
returns a
Flow<SaleEntity?>
instead of a List, however it still compiles.
override fun read(key: SalesRequestKey): Flow<List<Sale>> = flow {
        when (key) {
            SalesRequestKey.AllSales -> emitAll(
                salesLocalDataSource.fetchAllSales()
                    .map { saleEntities -> saleEntities.map(saleEntityToDomainSaleEntityMapper) }
            )
            is SalesRequestKey.SingleSaleRequest -> emitAll(
                salesLocalDataSource.fetchSaleWithPhotosById(
                    key.saleId
                ).filterNotNull()
                    .map { saleEntity -> saleEntityToDomainSaleEntityMapper.invoke(saleEntity) }
            )
    }
m

molikuner

07/23/2020, 11:28 AM
Does the
saleEntityToDomainSaleEntityMapper.invoke
return
List<Sale>
?
a

Ahmed Ibrahim

07/23/2020, 11:49 AM
Nope, that's the signature in the ctor
private val saleEntityToDomainSaleEntityMapper:
Mapper<@JvmSuppressWildcards SaleEntity, @JvmSuppressWildcards Sale>