Router

class Router<T>(defaultRoute: Route<T>)

Router register the event-listener for hashchange-event and handles route-changes. Therefore it uses a Route object which can Route.serialize and Route.deserialize the given type.

Parameters

T

type to marshal and unmarshal

Constructors

Router
Link copied to clipboard
js
fun <T> Router(defaultRoute: Route<T>)
type to marshal and unmarshal

Functions

equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
toString
Link copied to clipboard
js
open fun toString(): String

Properties

current
Link copied to clipboard
js
val current: T
Gives the current route T.
data
Link copied to clipboard
js
val data: Flow<T>
Gives a Flow of T for rendering the site depending on the current route.
navTo
Link copied to clipboard
js
val navTo: SimpleHandler<T>
Handler for setting a new Route based on given Flow.

Extensions

select
Link copied to clipboard
js
fun Router<Map<String, String>>.select(key: String): Flow<Pair<String?, Map<String, String>>>
Selects with the given key a Pair of the value and all routing parameters as Map.
fun Router<Map<String, String>>.select(key: String, orElse: String): Flow<String>
Returns the value for the given key from the routing parameters.