Skip to content

Instantly share code, notes, and snippets.

View pratishjage's full-sized avatar
🎯
Focusing

Pratish Jage pratishjage

🎯
Focusing
  • Pepperfry
  • Mumbai
View GitHub Profile
sealed class BaseUiState<out R> {
data class Success<R>(val data: R) : BaseUiState<R>()
data class Error(val error: Any) : BaseUiState<Nothing>()
data class Loading(val isLoading: Boolean) : BaseUiState<Nothing>()
}
sealed class BaseResult<out R : Any, out E : Any> {
data class Success<R : Any>(val data: R) : BaseResult<R, Nothing>()
@pratishjage
pratishjage / ConcurrencyHelpers.kt
Created June 21, 2020 09:48 — forked from objcode/ConcurrencyHelpers.kt
Helpers to control concurrency for one shot requests using Kotlin coroutines.
import kotlinx.coroutines.CoroutineStart.LAZY
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.yield
import java.util.concurrent.atomic.AtomicReference
import kotlin.DeprecationLevel.ERROR