kreuzberg.Component.scala Maven / Gradle / Ivy
package kreuzberg
import kreuzberg.dom.ScalaJsElement
/**
* The base for all UI components.
*
* In practice you should use [[ComponentBase]] or [[SimpleComponentBase]]
*/
trait Component extends Identified {
/** Identifier of the component. */
final val id = Identifier.next()
/** Data type of JS Representation. */
type DomElement <: ScalaJsElement
/** Assemble the object. */
def assemble(using context: AssemblerContext): Assembly
/**
* Update the component into a new state. By default components are re-rendered.
*
* Overriding this method can improve performance, if a component generates large sub-trees and we do not want to
* rebuild everything (e.g. List-Components).
*/
def update(before: ModelValueProvider)(using context: AssemblerContext): UpdateResult = {
UpdateResult.Build(assemble)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy