diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-01-31 00:08:01 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-01-31 00:08:01 +0100 |
commit | b095a2ff0284cb641cd3c7eb5cba09923304c55f (patch) | |
tree | 9a65656279e4b1499904a562a9d9aef02bcf04ab /src/main/kotlin/pl/treksoft/kvision/data | |
parent | d7059e321f796301c19cb1b9746eb3e27d7480bd (diff) | |
download | kvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.tar.gz kvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.tar.bz2 kvision-b095a2ff0284cb641cd3c7eb5cba09923304c55f.zip |
Data container update handler
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/data')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt | 12 |
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 + } } |