MiddlewareSwitcher

A Middleware that can switch between different Middleware instances.

Parameters

default

The default Middleware implementation.

Constructors

Link copied to clipboard
constructor(default: M)

Properties

Link copied to clipboard

Returns current state of middleware, true if already attached, false otherwise

Link copied to clipboard
val middlewareState: StateFlow<M>

Active middleware state

Functions

Link copied to clipboard
fun detach()

Function called to detach middleware context if it exists

Link copied to clipboard
open override fun onAttached(middlewareContext: C)
Link copied to clipboard
open override fun onDetached(middlewareContext: C)
Link copied to clipboard
fun registerMiddleware(middleware: M)

Registers a new middleware instance.

Link copied to clipboard
fun <S> stateFlowOf(started: SharingStarted = SharingStarted.Eagerly, func: M.() -> S): StateFlow<S>

Creates a StateFlow that maps the current middleware state to a derived state of type S.

Link copied to clipboard

Unregisters the currently active middleware and restores the default middleware.