diff --git a/build.gradle b/build.gradle index 2a4a1929fc..d08237466a 100755 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ ext { } group 'com.github.kwebio' -version '0.7.11' +version '0.7.12' repositories { mavenCentral() diff --git a/src/main/kotlin/kweb/prelude.kt b/src/main/kotlin/kweb/prelude.kt index 449ccadbee..66fc08f652 100644 --- a/src/main/kotlin/kweb/prelude.kt +++ b/src/main/kotlin/kweb/prelude.kt @@ -406,8 +406,8 @@ val KVar.pathQueryFragment fun Pair, KVar>.combine(): KVar> { val newKVar = KVar(this.first.value to this.second.value) - this.first.addListener { o, n -> newKVar.value = n to this.second.value } - this.second.addListener { o, n -> newKVar.value = this.first.value to n } + this.first.addListener { _, n -> newKVar.value = n to this.second.value } + this.second.addListener { _, n -> newKVar.value = this.first.value to n } newKVar.addListener { o, n -> this.first.value = n.first @@ -427,7 +427,17 @@ fun KVar.toInt() = this.map(object : ReversibleFunction(lab } }) - -fun ElementCreator<*>.renderEach(collection : KVar>, block : ElementCreator.(value : T, index : Int) -> Unit) { - +/** + * Render each element of a List + */ +fun ElementCreator<*>.renderEach(list : KVar>, block : ElementCreator.(value : KVar) -> Unit) { + /* + * TODO: This will currently re-render the collection if the list size changes, rather than modifying existing + * DOM elements - this is inefficient. + */ + render(list.map { it.size }) { size -> + for (ix in 0 until size) { + block(list[ix]) + } + } } \ No newline at end of file