aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt12
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
index 2c87daea..6f9dfaeb 100644
--- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
@@ -20,6 +20,8 @@ class DataContainer<M : DataComponent, C : Widget>(
child.visible = value
}
+ internal var onUpdateHandler: (() -> Unit)? = null
+
init {
child.parent = this
model.onUpdate += { _ ->
@@ -64,6 +66,16 @@ class DataContainer<M : DataComponent, C : Widget>(
child.removeAll()
child.addAll(model.mapIndexed { index, _ -> binding(index) })
}
+ onUpdateHandler?.invoke()
+ }
+
+ fun onUpdate(handler: () -> Unit): DataContainer<M, C> {
+ onUpdateHandler = handler
+ return this
}
+ fun clearOnUpdate(): DataContainer<M, C> {
+ onUpdateHandler = null
+ return this
+ }
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
index 62f8c239..0367633c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
@@ -54,6 +54,7 @@ interface BtOn : On {
var hideBsDateTime: ((KvEvent) -> kotlin.Unit)?
var onMinBsSpinner: ((KvEvent) -> kotlin.Unit)?
var onMaxBsSpinner: ((KvEvent) -> kotlin.Unit)?
+ var updateModel: ((KvEvent) -> kotlin.Unit)?
}
interface SnOn<T> : BtOn {