Skip to content

Instantly share code, notes, and snippets.

@nphausg
Created September 12, 2024 01:25
Show Gist options
  • Save nphausg/3315ccfe170e4d20aded2b7b8c01c9dd to your computer and use it in GitHub Desktop.
Save nphausg/3315ccfe170e4d20aded2b7b8c01c9dd to your computer and use it in GitHub Desktop.
// Domain
class AppConfig(val name: String)
// Data
internal class AppConfigResponse(
val id: String,
val name: String
)
internal class AppConfigRepositoryImpl : AppConfigRepository {
override suspend fun getConfig(
onSuccess: (AppConfig) -> Unit, onFailure: (Throwable?) -> Unit
) {
withContext(Dispatchers.IO) {
try {
val id = UUID.randomUUID().toString()
val response = AppConfigResponse(id, id.substring(0, 10))
onSuccess(AppConfig(name = response.name))
} catch (e: Exception) {
onFailure(e)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment