commonMain.captain.Router.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of captain-router-compose-core Show documentation
Show all versions of captain-router-compose-core Show documentation
A compose router that follows any type of navigator
package captain
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@Composable
fun Router(
start: String = "/",
navigator: Navigator = BasicNavigator(start),
content: @Composable () -> Unit
) {
if (start != navigator.current().path) navigator.navigate(start)
CompositionLocalProvider(LocalNavigator provides navigator) {
content()
}
}