diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt index c7bc5a0..81cf098 100644 --- a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt @@ -69,18 +69,19 @@ class App( val imgSrc = img.src.substringBeforeLast('?') println("fetching $imgSrc") - val newImg = Image() + var newImg : Image? = Image() - newImg.onload = { + newImg!!.onload = { window.requestAnimationFrame { - println("image loaded ${newImg.src}") + println("image loaded ${newImg!!.src}") img.setAttribute("dynamic-reload", "true") - img.src = newImg.src + img.src = newImg!!.src + newImg = null // try to encourage garbage collection Unit } } - newImg.src = imgSrc //+ "?t=${currentTimeMillis()}" + newImg!!.src = imgSrc //+ "?t=${currentTimeMillis()}" } } }