Guidance on implementing the Data Layer using Repository pattern, Room (Local), and Retrofit (Remote) with offline-first synchronization.
47
48%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.github/skills/architecture/android-data-layer/SKILL.mdThe Data Layer coordinates data from multiple sources.
class NewsRepository @Inject constructor(
private val newsDao: NewsDao,
private val newsApi: NewsApi
) {
// Expose data from Local DB as the source of truth
val newsStream: Flow<List<News>> = newsDao.getAllNews()
// Sync operation
suspend fun refreshNews() {
val remoteNews = newsApi.fetchLatest()
newsDao.insertAll(remoteNews)
}
}@Entity data classes.Flow<T> for observable data.suspend functions in interfaces.try-catch blocks or a Result wrapper to handle exceptions (NoInternet, 404, etc.) gracefully.WorkManager to push changes to server.@Binds
abstract fun bindNewsRepository(impl: OfflineFirstNewsRepository): NewsRepositorye5d0275
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.