From 32ddb5789a4f9b644836d3a0cc2f9b14b37b5e5b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 7 Mar 2018 00:09:02 +0100 Subject: Add model parameter to DataContainer callback functions. --- src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index f71cee9f..99c8abf4 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -42,8 +42,8 @@ import pl.treksoft.kvision.panel.VPanel */ class DataContainer( private val model: ObservableList, - private val binding: (Int) -> C, - private val filter: ((Int) -> Boolean)? = null, + private val binding: (Int, M) -> C, + private val filter: ((Int, M) -> Boolean)? = null, private val child: Container = VPanel(), init: (DataContainer.() -> Unit)? = null ) : @@ -106,10 +106,10 @@ class DataContainer( child.removeAll() val indexed = model.mapIndexed { index, m -> index to m } val children = if (filter != null) { - indexed.filter { p -> filter.invoke(p.first) } + indexed.filter { p -> filter.invoke(p.first, p.second) } } else { indexed - }.map { p -> binding(p.first) } + }.map { p -> binding(p.first, p.second) } child.addAll(children) } onUpdateHandler?.invoke() @@ -142,8 +142,8 @@ class DataContainer( */ fun Container.dataContainer( model: ObservableList, - binding: (Int) -> C, - filter: ((Int) -> Boolean)? = null, + binding: (Int, M) -> C, + filter: ((Int, M) -> Boolean)? = null, child: Container = VPanel(), init: (DataContainer.() -> Unit)? = null ): DataContainer { -- cgit