History

class History<T>(capacity: Int, initialEntries: List<T>, val job: Job) : WithJob

Keeps track of historical values (i.e. of a Store) and allows you to navigate back in history

Parameters

capacity

max number of entries in history

initialEntries

initial entries in history

job

Job to be used by the History

Constructors

Link copied to clipboard
constructor(capacity: Int, initialEntries: List<T>, job: Job)

Properties

Link copied to clipboard
val available: Flow<Boolean>

Flow describing, if a value is available in the history

Link copied to clipboard
val current: List<T>

Represents the current entries in history.

Link copied to clipboard
val data: Flow<List<T>>

Gives a Flow with the entries of the history.

Link copied to clipboard
open override val job: Job

Functions

Link copied to clipboard
fun back(): T

Gets the lastest history-entry that has been added and removes it from the history.

Link copied to clipboard
fun clear()

clears the history.

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

Default error handler printing the error to console.

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
fun <T> WithJob.history(capacity: Int = 0, initialValue: List<T> = emptyList(), job: Job = this.job): History<T>

factory-method to create a History

Link copied to clipboard
fun push(entry: T)

Pushes a new entry to the history

Link copied to clipboard
fun <D> WithJob.storeOf(initialData: D, job: Job = this.job, id: String = Id.next()): Store<D>

Convenience function to create a simple Store without any handlers, etc.

fun <D, M> WithJob.storeOf(initialData: D, validation: Validation<D, Unit, M>, job: Job = this.job, id: String = Id.next()): ValidatingStore<D, Unit, M>

Convenience function to create a simple ValidatingStore without any metadata and handlers.

fun <D, T, M> WithJob.storeOf(initialData: D, validation: Validation<D, T, M>, metadataDefault: T, job: Job = this.job, id: String = Id.next()): ValidatingStore<D, T, M>

Convenience function to create a simple ValidatingStore without any handlers, etc.