commonTest.app.softwork.routingcompose.MockRouter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of routing-compose Show documentation
Show all versions of routing-compose Show documentation
A multiplatform library for routing to use with JetPack Compose Web and Desktop
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