Skip to content

Commit

Permalink
bump build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed May 9, 2020
1 parent 6a5b925 commit 149e29d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ext {
}

group 'com.github.kwebio'
version '0.7.11'
version '0.7.12'

repositories {
mavenCentral()
Expand Down
20 changes: 15 additions & 5 deletions src/main/kotlin/kweb/prelude.kt
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ val KVar<URL>.pathQueryFragment

fun <A, B> Pair<KVar<A>, KVar<B>>.combine(): KVar<Pair<A, B>> {
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
Expand All @@ -427,7 +427,17 @@ fun KVar<String>.toInt() = this.map(object : ReversibleFunction<String, Int>(lab
}
})


fun <T : Any?> ElementCreator<*>.renderEach(collection : KVar<Iterable<T>>, block : ElementCreator<Element>.(value : T, index : Int) -> Unit) {

/**
* Render each element of a List
*/
fun <T : Any> ElementCreator<*>.renderEach(list : KVar<List<T>>, block : ElementCreator<Element>.(value : KVar<T>) -> 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])
}
}
}

0 comments on commit 149e29d

Please sign in to comment.