This is related to binding-scala-strategy-to-avoid-too-many-dom-tree-updates
In my project scala-adapters I display log entries that are sent over a websocket.
I have no control on how many entries are sent. So if there are a lot of entries the screen freezes.
I created a ScalaFiddle to simulate that: https://scalafiddle.io/sf/kzr28tq
What is the way to restrict the length of the entries (Vars) or what is the best strategy to drop the first entry of a Vars if the maximum length is reached?
A couple options:
If you don't need to keep all the data around, simply replace it in the ListBuffer: https://scalafiddle.io/sf/fsaJbkc/2
If you do need to keep all the data around but want to display a subset, use another Binding based off the first: https://scalafiddle.io/sf/i75YiYN/2
No change here:
entries.value += (0 to 1000).map(_=>Random.nextInt(9)).mkString("")