Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an event/hook for other plugins to hook into, to avoid race conditions #924

Closed
dvcrn opened this issue Nov 17, 2022 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@dvcrn
Copy link

dvcrn commented Nov 17, 2022

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

Hi! I am maintaining filename-heading-sync and it's currently not playing nicely with templater, see

Describe the solution you'd like

I don't want to add an artificial delay before acting on obsidian events, but as a solution, if we could detect that templater is installed, we could wait for a custom event (emitted by Templater) before doing things like renaming files or inserting headings.

Some ideas:

Maybe related: #883

@franciskafieh
Copy link

Also having this issue. Using the new Vaut#process (https://marcus.se.net/obsidian-plugin-docs/reference/typescript/classes/Vault#process) function in both plugins should supposedly fix this. Basically, process allows for atomic modification of the file

@franciskafieh
Copy link

if anyone wants to take on converting all of Templater's vault.modify, .append, etc to .process, it would be great. Otherwise I can get a PR out within the next week

@Zachatoo
Copy link
Collaborator

Templater is already emitting an event (multiple events, actually, depending on what you want). The creases plugin is the only plugin I know of that is currently hooking into these events.

Moving to app.vault.process() will be tricky, as Templater processes changes asynchronously, and app.vault.process() has to be run synchronously. There will have to be some sort of diff processing if we switch.

@franciskafieh
Copy link

No problem. For now, there's a workaround with my plugin, so not urgent on my end. Thanks for the consideration, though

@Zachatoo
Copy link
Collaborator

Since Templater is already emitting an event, going to mark this as closed. Thanks everyone for your contributions to this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants