aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/data
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-12 10:50:42 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-12 10:50:42 +0100
commitbafcdb6fc3f1d4ec4f1a0f4fcce776ba10d8136c (patch)
tree39288bdcb59ec48cb70f1c5820fc1854949744da /src/main/kotlin/pl/treksoft/kvision/data
parent2feea5e7cf8d492663e826ebcfb0a58e61820352 (diff)
downloadkvision-bafcdb6fc3f1d4ec4f1a0f4fcce776ba10d8136c.tar.gz
kvision-bafcdb6fc3f1d4ec4f1a0f4fcce776ba10d8136c.tar.bz2
kvision-bafcdb6fc3f1d4ec4f1a0f4fcce776ba10d8136c.zip
Type safe DSL builders
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/data')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt16
1 files changed, 16 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 13b5ce00..fa545dc8 100644
--- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
@@ -123,4 +123,20 @@ class DataContainer<M : DataComponent, C : Component>(
onUpdateHandler = null
return this
}
+
+ companion object {
+ /**
+ * DSL builder extension function
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+ fun <M : DataComponent, C : Component> Container.dataContainer(
+ model: ObservableList<M>,
+ binding: (Int) -> C,
+ child: Container = VPanel(),
+ init: (DataContainer<M, C>.() -> Unit)? = null
+ ) {
+ this.add(DataContainer(model, binding, child, init))
+ }
+ }
}