Package dev.fritz2.components.typeAhead

Types

Proposal
Link copied to clipboard
js
typealias Proposal = suspend (Flow<String>) -> Flow<List<String>>

This type alias defines the type of the proposal function of a TypeAheadComponent

The typical pattern of writing such a function is to start with the implicit it and use common Flow operators on it (pun intended):

// just map the draft to a list:
val proposal: Proposal = {
it.map { draft -> /* ... some API call or alike */}
}

// combine the draft with some other Flow (controlled by some other component)
val languages = storeOf(listOf("Kotlin", "Scala", "Java", "OCaml", "Haskell"))
val proposal: Proposal = {
it.combine(languages.data) { draft, languages -> /* check if draft is contained or alike */}
}
TypeAheadComponent
Link copied to clipboard
js
open class TypeAheadComponent(valueStore: Store<String>?, items: Proposal) : Component<Unit> , InputFormProperties, SeverityProperties, InputFieldProperties
This component class manages the configuration of a TypeAheadComponent and does the rendering.

Functions

asProposal
Link copied to clipboard
js
fun List<String>.asProposal(predicate: (String) -> (String) -> Boolean = { draft -> { item -> item.contains( draft, ignoreCase = true ) } }): Proposal
This extension function offers a short, convenience method to use a static List as Proposal.