Skip to content

Instantly share code, notes, and snippets.

@Marchuck
Created June 14, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marchuck/d48bc5d0f78d65681b9cc19c6c509c31 to your computer and use it in GitHub Desktop.
Save Marchuck/d48bc5d0f78d65681b9cc19c6c509c31 to your computer and use it in GitHub Desktop.
class GetPeopleUseCase(private val api: StarWarsApi) {
fun execute(page: Int): Deferred<List<Person?>?> {
return async { transform(page) }
}
private suspend fun transform(page: Int): List<Person?> {
val response = api.getPeople(page).await()
return response.results ?: emptyList()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment