Package de.peekandpoke.kraft.addons.routing

Types

Link copied to clipboard
data class ActiveRoute(    val uri: String,     val matchedRoute: Route.Match,     val mountedRoute: MountedRoute)

Represent the route that is currently selected as active route by a Router

Link copied to clipboard
data class MountedRoute(    val route: Route,     val middlewares: List<RouterMiddleware>,     val view: FlowContent.(Route.Match) -> Unit)

Represents a Route that is mounted by a Router

Link copied to clipboard
interface Route

Common Route representation

Link copied to clipboard
open class Route1(val pattern: String) : RouteBase

A parameterized route with one route parameter

Link copied to clipboard
open class Route2(val pattern: String) : RouteBase

A parameterized route with two route parameter

Link copied to clipboard
open class Route3(val pattern: String) : RouteBase

A parameterized route with two route parameter

Link copied to clipboard
open class Route4(val pattern: String) : RouteBase

A parameterized route with two route parameter

Link copied to clipboard
open class Route5(val pattern: String) : RouteBase

A parameterized route with two route parameter

Link copied to clipboard
abstract class RouteBase(val pattern: String, numParams: Int) : Route

A parameterized route with one route parameter

Link copied to clipboard
class Router(mountedRoutes: List<MountedRoute>, enabled: Boolean)

The Router

Link copied to clipboard
class RouterBuilder

Helper class for building a Router

Link copied to clipboard
class RouterComponent : Component<RouterComponent.Props>
Link copied to clipboard
typealias RouterMiddleware = RouterMiddlewareContext.() -> Unit

A RouterMiddleware is just a function with RouterMiddlewareContext as the receiver

Link copied to clipboard
class RouterMiddlewareContext(    val router: Router,     val uri: String,     val match: Route.Match)

The context for all middle wares

Link copied to clipboard
typealias RouterProvider = () -> Router
Link copied to clipboard
open class Static(val pattern: String) : RouteBase

A static route is a route that does not have any route parameters

Functions

Link copied to clipboard
fun navigateTo(uri: String)
Link copied to clipboard
fun router(builder: RouterBuilder.() -> Unit): Router
Link copied to clipboard
fun Tag.RouterComponent(router: Router): ComponentRef<RouterComponent>

The router component displays the view that is associated with the ActiveRoute of the given Router

Link copied to clipboard
fun routerMiddleware(func: RouterMiddleware): RouterMiddleware

Helper for defining a router middleware

Link copied to clipboard
fun <C> Component<C>.urlParam(    router: Router,     name: String,     default: Int,     onChange: (Int) -> Unit? = null): ReadWriteProperty<Component<C>, Int>
fun <C> Component<C>.urlParam(    router: Router,     name: String,     default: String,     onChange: (String) -> Unit? = null): ReadWriteProperty<Component<C>, String>
Link copied to clipboard
fun <C, T> Component<C>.urlParams(    router: Router,     fromParams: (Map<String, String>) -> T,     toParams: (T) -> Map<String, Any?>,     onChange: (T) -> Unit? = null): ReadWriteProperty<Component<C>, T>