aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/data')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt12
1 files changed, 12 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
+ }
}