kweb-core
kweb-core copied to clipboard
Reduce unnecessary DOM rendering from renderEach() in prelude.kt
Create an extension function for rendering Collections within KVars:
val c : KVar<List<Int>> = KVar(listOf(1, 2, 3))
// inside Kweb {}
renderEach(c) { v : KVar<Int> ->
h1().text(v.map { it.toString() })
}
The trick here will be to efficiently handle element insertion and deletion while minimizing DOM modifications.
see also: https://github.com/kwebio/kweb-core/issues/123#issuecomment-622941084
Simple implementation of this here released in 0.7.12, although unnecessarily re-renders list if the list size changes so leaving this issue open until that can be made more efficient.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.