Skip to content

Instantly share code, notes, and snippets.

@MaxMichel2
Created October 3, 2024 12:00
Show Gist options
  • Save MaxMichel2/8baeb48a1e99a637d8cbf43cf3181995 to your computer and use it in GitHub Desktop.
Save MaxMichel2/8baeb48a1e99a637d8cbf43cf3181995 to your computer and use it in GitHub Desktop.
class TopicsRepositoryImpl @Inject constructor(
private val topicsDataSource: TopicsDataSource
) : TopicsRepository {
override suspend fun getTopics(): DataResult<List<Topic>, TopicsRepositoryError> {
return safeApiCall(
apiCall = { topicsDataSource.getTopics() },
onError = { statusCode ->
when (statusCode) {
StatusCode.NoContent -> TopicsRepositoryError.NoTopics
else -> null
}
}
)
}
// Other API calls
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment