Having this: ```fun getAllBusStops(): Flow<List...
# android
p
Having this:
Copy code
fun getAllBusStops(): Flow<List<BusStopEntity>>
and this extension function to transform the BusStopEntity in a BusStop class:
Copy code
fun BusStopEntity.asBusStop() = BusStop(id = id,name = name,lat = lat,lon = lon)
How can I convert the Flow<List<BusStopEntity>> in a Flow<List<BusStop>> using that extension function?
🧵 2
g
you can use the kotlin
map
operator, something like:
Copy code
fun getAllBusStops(): Flow<List<BusStop>> {
    return getAllBusStops()
        .map { entityList ->
            entityList.map { it.asBusStop() }
        }
}
☝️ 1
p
two map encapsulated? is that correct?
maybe there is a simpler way to achieving what I need? i just need to do this: my database returns a flow of entities, and I need my repo to return that flow of entities transformed in a flow of normal classes