All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kreuzberg.Component.scala Maven / Gradle / Ivy

There is a newer version: 0.10.3
Show newest version
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