DatabindingProperty

This property keeps track of the external data-binding of some component.

There are exactly four parts that defines a fully functional data-binding:

  • an id

  • the data to react to change from the external data source

  • a handler to push changes to the external data holder

  • a messages to react to the external validation state

This property enables components to expose a uniform API to plug the external data source into a component.

All four parts can be set individually by the basic invoke operation, but there is also a convenience invoke function, which accepts a Store of T and automatically grab the four aspects out of it.

As only the data field is mandatory, this Property enables one-way-data-binding as well as two-way-data-binding.

In order to deal nicely with ComponentValidationMessages, there are two convenience functions to use:

  • hasError offers a Boolean that simply signals if there are errors at all or not. This is especially useful for components, that display such messages. Often the DOM structure can be simplified if there is no message.

  • validationMessages offers a none null Flow which can be used to render the messages without nullability checks.

Constructors

Link copied to clipboard

Types

Link copied to clipboard
data class DataBinding<T>(val id: String? = null, val data: Flow<T>, val handler: (Flow<T>) -> Unit? = null, val messages: Flow<List<ComponentValidationMessage>>? = null)

Functions

Link copied to clipboard
operator fun invoke(store: Store<T>)
operator fun invoke(id: String? = null, data: Flow<T>, messages: Flow<List<ComponentValidationMessage>>? = null, handler: (Flow<T>) -> Unit? = null)
Link copied to clipboard

Properties

Link copied to clipboard
val data: Flow<T>
Link copied to clipboard
val handler: (Flow<T>) -> Unit?
Link copied to clipboard
val hasError: Flow<Boolean>
Link copied to clipboard
val id: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard