Store

interface Store<T> : WithJob

The Store is the main type for all data binding activities. It the base class of all concrete Stores like RootStore, SubStore, etc.

Functions

enqueue
Link copied to clipboard
js
abstract suspend fun enqueue(update: QueuedUpdate<T>)
abstract method defining, how this Store handles an Update
equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
errorHandler
Link copied to clipboard
js
open fun errorHandler(exception: Throwable, oldValue: T): T
Default error handler printing the error to console and keeping the previous value.
handle
Link copied to clipboard
js
open fun handle(errorHandler: ErrorHandler<T> = ::errorHandler, execute: suspend (T) -> T): SimpleHandler<Unit>
Factory method to create a SimpleHandler that does not take an Action
open fun <A> handle(errorHandler: ErrorHandler<T> = ::errorHandler, execute: suspend (T, A) -> T): SimpleHandler<A>
Factory method to create a SimpleHandler mapping the actual value of the Store and a given Action to a new value.
handleAndEmit
Link copied to clipboard
js
open fun <E> handleAndEmit(errorHandler: ErrorHandler<T> = ::errorHandler, execute: suspend FlowCollector<E>.(T) -> T): 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(errorHandler: ErrorHandler<T> = ::errorHandler, execute: suspend FlowCollector<E>.(T, A) -> T): EmittingHandler<A, E>
Factory method to create a EmittingHandler taking an action-value and the current store value to derive the new value.
handledBy
Link copied to clipboard
js
open infix fun <E : Event, X : Element> DomListener<E, X>.handledBy(handler: Handler<Unit>)
Connects Events to a Handler.
open infix fun <E : Event> WindowListener<E>.handledBy(handler: Handler<Unit>)
Connects Events to a Handler.
open infix fun <A> Flow<A>.handledBy(handler: Handler<A>)
Connects a Flow to a Handler.
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
syncBy
Link copied to clipboard
js
open fun syncBy(handler: Handler<T>)
calls a handler on each new value of the Store
open fun syncBy(handler: Handler<Unit>)
calls a handler on each new value of the Store
syncWith
Link copied to clipboard
js
open fun <I> syncWith(socket: Socket, resource: Resource<T, I>)
toString
Link copied to clipboard
js
open fun toString(): String

Properties

current
Link copied to clipboard
js
abstract val current: T
represents the current value of the Store
data
Link copied to clipboard
js
abstract val data: Flow<T>
the Flow representing the current value of the Store.
id
Link copied to clipboard
js
abstract val id: String
base-id of this Store.
job
Link copied to clipboard
js
abstract val job: Job
update
Link copied to clipboard
js
abstract val update: Handler<T>
a simple SimpleHandler that just takes the given action-value as the new value for the Store.

Inheritors

RootStore
Link copied to clipboard
SubStore
Link copied to clipboard

Extensions

syncBy
Link copied to clipboard
js
inline fun <T, R> Store<T>.syncBy(handler: Handler<R>, crossinline mapper: suspend (T) -> R)
calls a handler on each new value of the Store
syncWith
Link copied to clipboard
js
fun <T, I> Store<List<T>>.syncWith(socket: Socket, resource: Resource<T, I>)
watch
Link copied to clipboard
js
fun <T> Store<T>.watch(scope: CoroutineScope = MainScope()): Store<T>
If a Store's data-Flow is never mounted, use this method to start the updating of derived values.