Skip to content

Instantly share code, notes, and snippets.

@yektasarioglu
Last active August 14, 2020 14:04
Show Gist options
  • Save yektasarioglu/d1473b7199453dcba87786443b9056d2 to your computer and use it in GitHub Desktop.
Save yektasarioglu/d1473b7199453dcba87786443b9056d2 to your computer and use it in GitHub Desktop.
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