Skip to content

Timing problems with creating a batch of notes. Can't get tp.hooks.on_all_templates_executed(callback_function: () => any working #1493

Answered by Zachatoo
Elkiehirvi asked this question in Help
Discussion options

You must be logged in to vote

the order of templates resolving is wrong

This because you are creating the files concurrently (see #1405 for another example of this). I would recommend creating the files sequentially. This will likely resolve most of the issues you're seeing.

// 🔴 creating files concurrently
dates.forEach(createInstance);

// ✅ creating files sequentially
for (const date in dates) {
  await createInstance(date);
}

As far as the hooks module goes, I suspect you should be able to implement it like this in your provided template, if you still need it.

// ...
async function createInstance(date) {
  // ...
+ tp.hooks.on_all_templates_executed(async () => {
    await app.fileManager.processFrontMatter(file…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Elkiehirvi
Comment options

Answer selected by Elkiehirvi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants