Skip to content

Instantly share code, notes, and snippets.

@cdsap
Created December 31, 2018 08:47
Show Gist options
  • Save cdsap/6e1d78d9e06f8930d036527e10d3d12c to your computer and use it in GitHub Desktop.
Save cdsap/6e1d78d9e06f8930d036527e10d3d12c to your computer and use it in GitHub Desktop.
SyncRepositoryImpl
class SyncRepositoryImpl<out T : LocalSource<E>, out R : RemoteSource<Q>, Q, E>(
private val db: T,
private val api: R,
private val mapper: Mapper<Q, E>
) : SyncRepository {
override fun sync() {
api.sync().forEach {
db.save(mapper.map(it))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment