aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-31 00:08:01 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-31 00:08:01 +0100
commitb095a2ff0284cb641cd3c7eb5cba09923304c55f (patch)
tree9a65656279e4b1499904a562a9d9aef02bcf04ab /src
parentd7059e321f796301c19cb1b9746eb3e27d7480bd (diff)
downloadkvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.tar.gz
kvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.tar.bz2
kvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.zip
Data container update handler
Diffstat (limited to 'src')
-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 {