Last active
August 14, 2020 14:04
-
-
Save yektasarioglu/d1473b7199453dcba87786443b9056d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private suspend fun getNearbyHealthInstitutions(radius: Meter = DEFAULT_KM_RADIUS): List<Site> { | |
return CoroutineScope(Dispatchers.IO).async { | |
val list = getHealthInstitutions() | |
val filteredList = list?.filter { it.city == userLocation?.state?.toUpperCase() } | |
val result = suspendCoroutine<List<Site>> { continuation -> | |
addNearbyHospitals( | |
radius = radius, | |
onEnd = { nearbyHealthInstitutions -> | |
compareHealthInstitutionLists( | |
officialHealthInstitutions = filteredList!!, | |
nearbyHealthInstitutions = nearbyHealthInstitutions | |
).let { found -> continuation.resume(found) } | |
}) | |
} | |
return@async result | |
}.await() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment