Skip to content

Instantly share code, notes, and snippets.

@leandroBorgesFerreira
Last active December 18, 2018 14:06
Show Gist options
  • Select an option

  • Save leandroBorgesFerreira/903eb6f89418b7fdec08aa9b24457449 to your computer and use it in GitHub Desktop.

Select an option

Save leandroBorgesFerreira/903eb6f89418b7fdec08aa9b24457449 to your computer and use it in GitHub Desktop.
class RepositoryDataSource<F>(
private val async: Async<F>,
private val apiClient: ApiClient
) {
fun fetchAllRepositories(): Kind<F, List<Repository>> =
async.run {
apiClient.getRepositories("Java", "star", 1)
.async(this)
.flatMap { response -> response.unwrapBody(this) }
.map { dto -> dto.items }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment