WebComponent

abstract class WebComponent<T : Element>(observeAttributes: Boolean)

Implement this class to build a WebComponent.

Constructors

WebComponent
Link copied to clipboard
js
fun WebComponent(observeAttributes: Boolean = true)

Functions

adoptedCallback
Link copied to clipboard
js
open fun adoptedCallback(element: HTMLElement)
lifecycle-callback that is called, when an instance is adopted by another DOM
attributeChanges
Link copied to clipboard
js
fun attributeChanges(name: String): Flow<String>
convenience method to get a Flow of the changes of a specific observed attributes.
connectedCallback
Link copied to clipboard
js
open fun connectedCallback(element: HTMLElement)
lifecycle-callback that is called, when an instance of the component is added to the DOM
disconnectedCallback
Link copied to clipboard
js
open fun disconnectedCallback(element: HTMLElement)
lifecycle-callback that is called, when an instance of the component is removed from the DOM
equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
init
Link copied to clipboard
js
abstract fun TagContext.init(element: HTMLElement, shadowRoot: ShadowRoot): Tag<T>
this method builds the content of the WebComponent that will be added to it's shadow-DOM.
initializeInternal
Link copied to clipboard
js
fun initializeInternal(element: HTMLElement, shadowRoot: ShadowRoot): Tag<T>
linkStylesheet
Link copied to clipboard
js
fun linkStylesheet(shadowRoot: ShadowRoot, url: String)
call this method in init to link an external stylesheet.
setStylesheet
Link copied to clipboard
js
fun setStylesheet(shadowRoot: ShadowRoot, text: String)
call this method in add style information from a static String.
toString
Link copied to clipboard
js
open fun toString(): String

Properties

attributeChangedCallback
Link copied to clipboard
js
lateinit var attributeChangedCallback: (name: String, value: String) -> Unit
this callback is used, when building the component in native-js (since ES2015-classes are not supported by Kotlin/JS by now)
attributeChanges
Link copied to clipboard
js
val attributeChanges: Flow<Pair<String, String>>
a Flow of all changes made to observed attributes.