Package dev.fritz2.binding

Types

EmittingHandler
Link copied to clipboard
js
class EmittingHandler<A, E>(collectWithChannel: (Flow<A>, FlowCollector<E>, Job) -> Unit, flow: MutableSharedFlow<E>) : Handler<A> , Flow<E>
An EmittingHandler is a special Handler that constitutes a new Flow by itself.
ErrorHandler
Link copied to clipboard
js
typealias ErrorHandler<T> = (Throwable, T) -> T

Defines a type for handling errors in updates

Handler
Link copied to clipboard
js
interface Handler<A>
Base-interface of the different types of handlers
Patch
Link copied to clipboard
js
sealed class Patch<out T>
A Patch describes the changes made to a List.
QueuedUpdate
Link copied to clipboard
js
class QueuedUpdate<T>(update: Update<T>, errorHandler: (Throwable, T) -> T)
Type of elements in the update-queue of a Store
RootStore
Link copied to clipboard
js
open class RootStore<T>(initialData: T, id: String) : Store<T>
A Store can be initialized with a given value.
SimpleHandler
Link copied to clipboard
js
class SimpleHandler<A>(collect: (Flow<A>, Job) -> Unit) : Handler<A>
Defines, how to handle actions in your Store.
Store
Link copied to clipboard
js
interface Store<T> : WithJob
The Store is the main type for all data binding activities.
SubStore
Link copied to clipboard
js
class SubStore<R, P, T>(parent: Store<P>, lens: Lens<P, T>, root: Store<R>, rootLens: Lens<R, T>) : Store<T>
A Store that is derived from your RootStore or another SubStore that represents a part of the data-model of it's parent.
Update
Link copied to clipboard
js
typealias Update<T> = suspend (T) -> T

Defines a type for transforming one value into the next

WithJob
Link copied to clipboard
js
interface WithJob

Functions

invoke
Link copied to clipboard
js
operator fun Handler<Unit>.invoke()
Calls this handler exactly once.
mountSingle
Link copied to clipboard
js
fun <T> mountSingle(parentJob: Job, upstream: Flow<T>, set: suspend (T, T?) -> Unit)
collects the values of a given Flow one by one.
storeOf
Link copied to clipboard
js
fun <T> storeOf(initialData: T, id: String = ""): RootStore<T>
convenience method to create a simple RootStore without any handlers, etc.
sub
Link copied to clipboard
js
fun <T> RootStore<List<T>>.sub(index: Int): SubStore<List<T>, List<T>, T>
creates a SubStore using a RootStore as parent using the index in the list (do not use this, if you want to manipulate the list itself (add or move elements, filter, etc.).
fun <R, P, T> SubStore<R, P, List<T>>.sub(index: Int): SubStore<R, List<T>, T>
creates a SubStore using a SubStore as parent using the index in the list (do not use this, if you want to manipulate the list itself (add or move elements, filter, etc.).
fun <T, I> RootStore<List<T>>.sub(element: T, id: IdProvider<T, I>): SubStore<List<T>, List<T>, T>
creates a SubStore using a RootStore as parent using a given IdProvider.
fun <R, P, T, I> SubStore<R, P, List<T>>.sub(element: T, idProvider: IdProvider<T, I>): SubStore<R, List<T>, T>
creates a SubStore using another SubStore as parent using a given IdProvider.
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.
fun <T> Flow<T>.watch(scope: CoroutineScope = MainScope())
If a data-Flow is never mounted, use this method to start the updating of derived values.