diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-02-12 08:04:05 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-02-12 08:04:05 +0100 |
commit | 2feea5e7cf8d492663e826ebcfb0a58e61820352 (patch) | |
tree | 2586cefdd5bf15193158d92b53442608632cd9d9 /src/main/kotlin/pl/treksoft/kvision/data | |
parent | 4f1a7d4331ec802789009937cda5a1e0e2213cb4 (diff) | |
download | kvision-2feea5e7cf8d492663e826ebcfb0a58e61820352.tar.gz kvision-2feea5e7cf8d492663e826ebcfb0a58e61820352.tar.bz2 kvision-2feea5e7cf8d492663e826ebcfb0a58e61820352.zip |
DSL syntax for containers
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/data')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index 209c9ae6..13b5ce00 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -37,11 +37,13 @@ import pl.treksoft.kvision.panel.VPanel * @param model data model of type *ObservableList<M>* * @param binding a function which creates component C from data model at given index * @param child internal container (defaults to [VPanel]) + * @param init an initializer extension function */ class DataContainer<M : DataComponent, C : Component>( private val model: ObservableList<M>, private val binding: (Int) -> C, - private val child: Container = VPanel() + private val child: Container = VPanel(), + init: (DataContainer<M, C>.() -> Unit)? = null ) : Widget(setOf()), Container, DataUpdatable { @@ -59,6 +61,8 @@ class DataContainer<M : DataComponent, C : Component>( update() } update() + @Suppress("LeakingThis") + init?.invoke(this) } override fun add(child: Component): Container { |