From 9a70dcb74707dac6d7e88d9b75ddf36b17fd5632 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 29 Jan 2018 20:55:02 +0100 Subject: Simplified data container --- src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/pl') diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index 4dbceaea..32546bd5 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -9,7 +9,7 @@ import pl.treksoft.kvision.panel.VPanel class DataContainer( val model: ObservableList, - private val binding: (M, Int) -> C, + private val binding: (Int) -> C, private val child: Container = VPanel() ) : Widget(setOf()), Container, DataUpdatable { @@ -56,11 +56,13 @@ class DataContainer( return this.child.renderVNode() } + open fun get(index: Int) = model[index] + override fun update() { model.forEach { it.container = this } singleRender { child.removeAll() - child.addAll(model.mapIndexed { index, m -> binding(m, index) }) + child.addAll(model.mapIndexed { index, _ -> binding(index) }) } } -- cgit