Skip to content

Instantly share code, notes, and snippets.

Avatar

Bloder bloderxd

View GitHub Profile
View Mapper.kt
interface Mapper<P, V> {
fun P.toValue(): V
fun V.toPayload(): P
}
View consume_flow_extension.kt
sealed class HomeActions {
class ShowPosts(val posts: List<Post>) : HomeActions()
class ShowUsers(val users: List<User>) : HomeActions()
}
data class HomeState(val posts: List<Post> = listOf(), val user: List<User> = listOf())
private val homeActions: ConflatedBroadcastChannel<HomeActions> by lazy { ConflatedBroadcastChannel<HomeActions>() }
View BloderComparable.kt
interface BloderComparable<T> {
fun customCompareTo(b: T) : Int
}
// O(1)
fun <T : BloderComparable<T>> List<T>.firstComparableIsEqualsTo(item: T) : Boolean = this[0].customCompareTo(item) == 0
// O(n)
fun <T : BloderComparable<T>> List<T>.containsComparable(item: T) : Boolean = this.firstOrNull {
it.customCompareTo(item) == 0
View ContextValidation
class ContextValidation(private val validator: FormValidator) : DefaultValidation(validator) {
fun whenBrazil(conditions: BrazilValidations.() -> Unit) {
if (isBrazilApp()) BrazilValidations(validator).conditions()
}
fun whenColombia(conditions: ColombiaValidations.() -> Unit) {
if (isColombiaApp()) ColombiaValidations(validator).conditions()
}
You can’t perform that action at this time.