Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save leandroBorgesFerreira/f08ca1d6c83f0b63b6df825d069d8e2d to your computer and use it in GitHub Desktop.
class RepositoryDataSource<F>(
private val apiClient: ApiClient,
async: Async<F>
) : Async<F> by async {
fun fetchAllRepositories(): Kind<F, List<Repository>> =
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