Skip to content

Instantly share code, notes, and snippets.

Avatar

Quentin Colle quentin41500

View GitHub Profile
@quentin41500
quentin41500 / CartManager.kt
Last active Jun 8, 2021
Using Sealed class and LiveData to handle network request through the repository layer.
View CartManager.kt
/**
* Observable manager for saving the [Cart]'s resource information.
*/
class CartManager : LiveData<Resource<Cart?>>() {
init {
value = Success(null)
}
/**
View CoroutineUtils.kt
/**
* Execute [block] and operate [predicate] on returned value. Each retries can be separated by
* [delay] if necessary.
*
* @param count Number of tries before failing.
* @param delay Delay between retries
* @param block Code to execute
* @param predicate Predicate to execute.
*/
suspend fun <T> retryWithPredicate(