Skip to content

Instantly share code, notes, and snippets.

View jonatbergn's full-sized avatar
😊
gyshido

Jonathan Bergen jonatbergn

😊
gyshido
  • Hannover, Germany
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

typealias Given<Input> = (Input) -> Boolean
infix fun <Input, Violation> Given<Input>.violates(violation: Violation): (Input) -> Violation? =
{ if (invoke(it)) violation else null }
fun <Input> given(checkForFailure: Input.() -> Boolean) = checkForFailure
fun <Input, Violation> validatorOf(vararg criteria: (Input) -> Violation?): (Input) -> List<Violation> =
{ input -> criteria.mapNotNull { it(input) } }
class Milk
class Beans
class Powder
class Water
class Coffee(water: Water, powder: Powder)
sealed interface BrewResult {
class Success(val coffee: Coffee) : BrewResult
sealed interface Failure : BrewResult {
object InsufficientPowder : Failure
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.invoke
interface UseCase<State, Action> {
val actions: Flow<Action>
package com.jonathanbergen
import kotlinx.coroutines.Job
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.onStart