How do I determine if Obsidian has finished loading all notes?

If a note is set to open with Obsidian startup, and dataview is used for some queries in the note, it may fail to run the queries when the note cache is not fully loaded. How can I determine when it is loaded? It is possible to judge by repeatedly requesting the getAllLoadedFiles() method, but it doesn’t feel elegant enough.