consumingMiddleware

inline fun <State, T : Action> consumingMiddleware(crossinline block: MiddlewareScope<State>.(T) -> Unit): Middleware<State>

Creates a middleware with consumingDispatch that consumes actions with given supertype T. Other actions are passed to the next middleware.

Example of usage:

sealed interface CustomAction : Action {
object A : CustomAction
object B : CustomAction
}

fun customMiddleware() = consumingMiddleware<AppState, CustomAction> { action ->
when (action) { // this when is exhaustive!
CustomAction.A -> TODO()
CustomAction.B -> TODO()
}
}