Naming The Async Function - Part 1

September 15, 2023

Here's an example of async function :

js
async function foo() {
  // todo
}

Sometimes I prefer to call it without the blocking. but in this case I wouldn't know if this was an async function.

js
// is this async function?
foo();

I've recently worked on C# project and so I though a task prefix would be useful for async function naming in JavaScript.

js
async function taskFoo() {
  // todo
}

taskFoo();

This way I know in a glance that this is an async function and use await if needed.

js
// don't need to use await
taskFoo();

// need to use await
await taskFoo();

Improving from Here

The next approach groups the async functions definitions and remove the "Task-" prefix to improve first letter search.

Continue to part 2.

Comments

Thank You

for your visit