MapRouter

open class MapRouter(defaultRoute: Map<String, String>) : Router<Map<String, String>>

Represents the current Route as Map of Strings.

Parameters

defaultRoute

default Route to start with.

Constructors

Link copied to clipboard
fun MapRouter(defaultRoute: Map<String, String> = emptyMap())

Functions

Link copied to clipboard
open suspend override fun enqueue(update: Update<Map<String, String>>)

abstract method defining, how this Store handles an Update

Link copied to clipboard
open fun errorHandler(cause: Throwable)

Default error handler printing the error to console.

Link copied to clipboard
open fun handle(execute: suspend (Map<String, String>) -> Map<String, String>): SimpleHandler<Unit>

Factory method to create a SimpleHandler that does not take an Action

open fun <A> handle(execute: suspend (Map<String, String>, A) -> Map<String, String>): SimpleHandler<A>

Factory method to create a SimpleHandler mapping the actual value of the Store and a given Action to a new value.

Link copied to clipboard
open fun <E> handleAndEmit(execute: suspend FlowCollector<E>.(Map<String, String>) -> Map<String, String>): EmittingHandler<Unit, E>

factory method to create an EmittingHandler that does not take an action in it's execute-lambda.

open fun <A, E> handleAndEmit(execute: suspend FlowCollector<E>.(Map<String, String>, A) -> Map<String, String>): EmittingHandler<A, E>

Factory method to create a EmittingHandler taking an action-value and the current store value to derive the new value. An EmittingHandler is a Flow by itself and can therefore be connected to other SimpleHandlers even in other Stores.

Link copied to clipboard
open infix fun <A> Flow<A>.handledBy(handler: Handler<A>)

Connects a Flow to a Handler.

open infix fun <A> Flow<A>.handledBy(execute: suspend (A) -> Unit): Job
open infix fun <E : Event> Flow<E>.handledBy(execute: suspend (E) -> Unit): Job

Connects a Flow to a suspendable execute function.

open infix fun <E : Event> Flow<E>.handledBy(handler: Handler<Unit>)

Connects Events to a Handler.

Link copied to clipboard
open operator fun Handler<Unit>.invoke()
open operator fun <A> Handler<A>.invoke(data: A)

Calls this handler exactly once.

Link copied to clipboard
open fun 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.

open fun select(key: String, orElse: String): Flow<String>

Returns the value for the given key from the routing parameters.

Link copied to clipboard
open fun <X> sub(lens: Lens<Map<String, String>, X>): SubStore<Map<String, String>, X>

create a SubStore that represents a certain part of your data model.

open fun sub(key: String): SubStore<Map<String, String>, String>

Selects with the given key a SubStore of the value.

Link copied to clipboard
open fun <D, I> Store<D>.syncWith(socket: Socket, resource: Resource<D, I>)

Syncs a Store by via a Websockets connection.

Properties

Link copied to clipboard
open override val current: Map<String, String>

represents the current value of the Store

Link copied to clipboard
open override val data: Flow<Map<String, String>>

the Flow representing the current value of the Store. Use this to bind it to ui-elements or derive calculated values by using map for example.

Link copied to clipboard
open override val id: String

id of this Store. ids of depending Stores are concatenated and separated by a dot.

Link copied to clipboard
open override val job: Job

Job for launching coroutines in.

Link copied to clipboard
open val navTo: SimpleHandler<Map<String, String>>

Navigates to the new given route provided as T.

Link copied to clipboard
open override val path: String

Path of this Store derived from the underlying model. Paths of depending Stores are concatenated and separated by a dot.

Link copied to clipboard
open override val update: SimpleHandler<Map<String, String>>

a simple SimpleHandler that just takes the given action-value as the new value for the Store.