Package dev.fritz2.routing

Types

Link copied to clipboard
open class MapRoute(default: Map<String, String>) : Route<Map<String, String>>

MapRoute serializes and deserializes a Map to and from window.location.hash. It is like using url parameters with pairs of key and value. At the start of the route is only a # instead of ?.

Link copied to clipboard
open class MapRouter(defaultRoute: Map<String, String>) : Router<Map<String, String>>

Represents the current Route as Map of Strings.

Link copied to clipboard
interface Route<T>

A Route is an abstraction for routes which needed for routing

Link copied to clipboard
open class Router<T>(defaultRoute: Route<T>) : Store<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.

Link copied to clipboard
open class StringRoute(default: String) : Route<String>

StringRoute is a simple Route which serializes and deserializes nothing.

Functions

Link copied to clipboard
external fun decodeURIComponent(encodedURI: String): String
Link copied to clipboard
external fun encodeURIComponent(decodedURI: String): String
Link copied to clipboard
fun <T> routerOf(default: Route<T>): Router<T>

Creates a new type based Router. Therefore, the given type must implement the Route interface.

fun routerOf(default: String = ""): Router<String>

Creates a new simple String based Router

fun routerOf(default: Map<String, String> = emptyMap()): MapRouter

Creates a new Map based Router