Skip to content

Instantly share code, notes, and snippets.

@octylFractal
Created July 9, 2020 20:57
Show Gist options
  • Save octylFractal/dffc4887566964e25fdb7b80738ceab3 to your computer and use it in GitHub Desktop.
Save octylFractal/dffc4887566964e25fdb7b80738ceab3 to your computer and use it in GitHub Desktop.
override fun getEquipment(type: String): Flow<Result<List<Equipment>>> {
return apiCallHandler.process { equipmentApi.getEquipment(type) }
.map { result ->
result.mapCatching { response ->
if (response.equipment.isNotEmpty()) {
response.equipment.map { it.toEquipment() }
} else {
throw EquipmentDataFailure.NoEquipmentFound
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment