obsidian-meta-bind-plugin icon indicating copy to clipboard operation
obsidian-meta-bind-plugin copied to clipboard

Possibility to run button js code synchronously

Open ujikol opened this issue 1 year ago • 1 comments

Please fill out these Check-boxes

  • [X] I checked for existing similar feature requests
  • [X] I have read the docs and checked that the feature I am requesting is not already implemented
  • [X] My feature request consists of only one feature

Is your Feature Request related to a Problem or Annoyance?

functions called in the inlineJS code of a button always run asynchronously even when called await. I guess that the whole code is called asynchronously. I need to run a code which runs for quite a few seconds, which changes the content of the editor (among others the text of the button). So during execution the user needs to be prevented from changing the editor or its content.

Describe the Feature you'd like

Option 1: Always run the code synchronously. The user code can make detach anyway. Option 2: Add flag to the button arguments Option 3: Create different action types inlineJs vs. inlineJsSync

Alternatives

No response

Additional Context

No response

ujikol avatar Sep 27 '24 15:09 ujikol

I guess that the whole code is called asynchronously.

Yes, since the entry point is an onclick hander, which is always queued as an async task.

If your code is sync, there should be no difference between running it in an async context or a sync one, as your code will be one big sync block and it will be executed by the JS Engine (not the plugin, but Chromium or Safari on iOS) as such. If your code is async, there is no way to run it "sync".

mProjectsCode avatar Sep 29 '24 09:09 mProjectsCode