From ddaa99a3ff9e502a67d11c5aca549a843cd1c3d7 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Fri, 27 Mar 2020 18:29:00 +0100 Subject: Add hooks to allow direct access to afterInsert and afterDestroy callbacks --- src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main/kotlin/pl/treksoft') diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index c03316ab..a1d37541 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -111,6 +111,9 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component protected var lastLanguage: String? = null + var afterInsertHook: ((VNode) -> Unit)? = null + var afterDestroyHook: (() -> Unit)? = null + protected fun singleRender(block: () -> T): T { getRoot()?.renderDisabled = true val t = block() @@ -630,6 +633,7 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component content = it.content?.let { translate(it) }).toJs() ) } + this.afterInsertHook?.invoke(node) } /** @@ -651,6 +655,7 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component val popoverFun = getElementJQueryD()?.popover if (popoverFun != undefined) getElementJQueryD()?.popover("dispose") } + this.afterDestroyHook?.invoke() } /** -- cgit