Skip to content

Instantly share code, notes, and snippets.

@DenisBronx
Created April 16, 2020 23:27
Show Gist options
  • Save DenisBronx/7d468f11bca15358d06e1d97def07327 to your computer and use it in GitHub Desktop.
Save DenisBronx/7d468f11bca15358d06e1d97def07327 to your computer and use it in GitHub Desktop.
class AlbumRepositoryImpl(
private val albumApiService: AlbumApiService,
private val mapAlbumDto: (NetworkAlbum) -> Album
) : AlbumRepository {
override fun getAlbumById(id: String): Single<SimpleResult<Album>> {
return albumApiService.getAlbumById(id).map {
it.fold(
success = { dto -> Result.Success(mapAlbumDto(dto)) },
failure = { throwable -> Result.Failure(throwable) }
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment