Guidance on implementing the Data Layer using Repository pattern, Room (Local), and Retrofit (Remote) with offline-first synchronization.
59
48%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./.github/skills/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): NewsRepository3f68e39
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.