-
-
Save nphausg/3315ccfe170e4d20aded2b7b8c01c9dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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