Created
February 24, 2021 11:39
-
-
Save AlexGladkov/fa09d81f63435eb5e2a27aa62361ca35 to your computer and use it in GitHub Desktop.
Repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CatalogVersionRepositoryImpl @Inject constructor( | |
private val catalogVersionRemoteDataSource: CatalogVersionRemoteDataSource, | |
private val catalogVersionLocalDataSource: CatalogVersionLocalDataSource | |
) : CatalogVersionRepository { | |
override fun checkNeedUpdate(): Single<Boolean> { | |
return catalogVersionRemoteDataSource.getCurrentCatalogVersion() | |
.map { remoteCatalogueVersion -> | |
val localCatalogueVersion = catalogVersionLocalDataSource.getCurrentCatalogVersion() | |
val hasActualVersion = localCatalogueVersion == remoteCatalogueVersion | |
catalogVersionLocalDataSource.saveCurrentCatalogVersion(remoteCatalogueVersion) | |
!hasActualVersion | |
} | |
.onErrorTypeJust<RemoteCatalogueVersionFetchError, Boolean>(false) | |
} | |
override fun clearCatalogVersion(): Completable { | |
return Completable.create { catalogVersionLocalDataSource.clearCurrentCatalogVersion() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment