Hi all - I have a plugin that has a lot to do upon application load - what will eventually be a long Promise chain. I’ve added an event handler for onLayoutReady() so that I can start my work after the app has calmed down. In the handler, I then kick off an await call to my function. It works brilliantly.
Callback binding: (in onLoad)
this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this));
Callback handler:
async onLayoutReady():Promise<void> {
var results = await this.DoABunchOfRidiculouslyLongWork();
}
But… I can’t help to think I am doing something wrong because if I look at the onLayoutReady() callback function def, it is clearly not intended for asynch use:
onLayoutReady(callback: () => any): void;
So my question is - how do I ensure my onLayoutReady() handler is actually being run with the ability to be asynchronous.
I appreciate the response - and realize this is more of a JS question than Obsidian, but thought the context of a plugin would make the question be handier for all.