in my plugin I’m adjusting the rendering of the reading mode via registerMarkdownPostProcessor().
I also need to react to changes of files (delete, rename, create) in that postprocessor function.
The listeners are working, I am just hitting my head on how to force a rerender of the reading mode - so that my postprocessor also runs again. Obsidian itself won’t do it since the file modification would only affect what I am adding in the postprocessor.
I already found rebuildView via app.workspace.getLeavesOfType("markdown")[0].rebuildView() (just as example). The downside of this approach is that there is a short flickering in the open reading mode tab. I would strive for a similar behavior as it happens when modifying files and internal links inside a note, which also appears to work seamlessly.
Does anyone have an idea to achieve that same behavior as for updating the internal links on file change?
@mnaoumov I did not try your suggestion since I found a way that works for me.
Instead, I looked up how the dataview plugin handles refreshable views and found this piece of code. This class is injected via MarkdownPostProcessorContext.addChild() into the postprocessor.
Even the Obsidian Docs recommend using MarkdownPostProcessorContext.addChild() to have lifecycle management inside the postprocessor.
This solved my problem, since I know can hook on obsidian events and then force a rerender of that child component.