obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Atomic updates of the whole Dataview JS block

Open rtmigo opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

Updating of Dataview JS causes flickering/jumping of both dataview block and content below it.

As I see, the view is updated in two steps:

  1. The old content is removed (height of the block becomes zero or so)
  2. The new content is added

Between 1 and 2 there is a noticeable time lag. After first step — dataview disappears, all text below the block jumps up. Then everything gets back.

Even if the updated content of dataview has the same height as old content, or it is exactly the same content — updating will cause flickering and jumping.

For me it is very noticeable problem: some of my pages are like dashboards (multiple status updates, reminders), and they are supposed to update each minute based on automated external sources. That's a lot of flickering!

Describe the solution you'd like

Introduce a method, that will allow to update the dataview in one step, like dv.rewrite(newContent).

This method could atomically replace old DOM element with new one, without clearing canvas before that.

Describe alternatives you've considered

  • Reducing calls of the API to single dv.paragraph()
  • Optimizing the code of my view to run as fast as possible
  • Minimizing changes in the updated content
  • Increasing "Refresh Interval" in the Dataview UI settings
  • Running Obsidian on powerful hardware with fast CPU

Additional context

I guess, the the reason of the current behavior is that the API is designed in imperative manner:

  • clear canvas
  • add view content (call renderValue)
  • add view content (call renderValue)
  • ...

But there will be no need in clearing canvas, if the user have no intention to add content more than once.

The main idea is to allow the user prepare all the content without touching the page (even if preparing is slow, it's not visible), and then only update DOM in "zero time".

rtmigo avatar May 28 '24 16:05 rtmigo