All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.app.softwork.routingcompose.MockRouter.kt Maven / Gradle / Ivy

Go to download

A multiplatform library for routing to use with JetPack Compose Web and Desktop

There is a newer version: 0.4.0
Show newest version
package app.softwork.routingcompose

import androidx.compose.runtime.*

class MockRouter : Router {
    override val currentPath: Path
        get() = Path.from(currentState.value!!)

    private val currentState = mutableStateOf(null)

    @Composable
    override fun getPath(initPath: String) =
        derivedStateOf { currentState.value ?: initPath }

    override fun navigate(to: String, hide: Boolean) {
        currentState.value = to
    }
}

@Composable
operator fun MockRouter.invoke(initPath: String, routeBuilder: @Composable RouteBuilder.() -> Unit) =
    route(initPath, routeBuilder)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy