rememberMobiusLoop

expect fun <M, E, F> rememberMobiusLoop(startModel: M, init: Init<M, F>? = null, loopBuilder: () -> MobiusLoop.Builder<M, E, F>): ComposeMobiusLoopStateHolder<M, E>

A Mobius Loop lifecycle handler bound to a Composable function or a ViewModel on Android targets using Jetpack Navigation.

The loop will be started immediately with startModel. To restore state from a previous loop instance, use a storage mechanism the platform provides to persist the model instance, then read it into startModel.

Create the loop outside the main Composable UI function. You should provide the model and event consumer function as parameters to maintain preview support. The loop setup would typically live at the same level as your navigation handler body for the associated route.

Return

An object holding the State<M> and Consumer<E>, destructure in that order.

Parameters

M

The Model with which the Mobius Loop will run

E

The Event type accepted by the loop

F

The Effect type handled by the loop

startModel

The initial model used when starting the loop.

init

The Init function to use when starting the loop

loopBuilder

A lambda which produces the loop builder to use.

actual fun <M, E, F> rememberMobiusLoop(startModel: M, init: Init<M, F>?, loopBuilder: () -> MobiusLoop.Builder<M, E, F>): ComposeMobiusLoopStateHolder<M, E>
actual fun <M, E, F> rememberMobiusLoop(startModel: M, init: Init<M, F>?, loopBuilder: () -> MobiusLoop.Builder<M, E, F>): ComposeMobiusLoopStateHolder<M, E>
actual fun <M, E, F> rememberMobiusLoop(startModel: M, init: Init<M, F>?, loopBuilder: () -> MobiusLoop.Builder<M, E, F>): ComposeMobiusLoopStateHolder<M, E>