Skip to content

Developers Code Style

George M. Dias edited this page Jul 23, 2024 · 8 revisions

Heimdall Developers Code Style

Vue

Heimdall development follows the Vue.js style guide provided by Vue.js Style Guide

Typescript

Heimdall development follows the TypeScript style guide provided by TS Style Guide


Common Practices

Use this space to add common code style practices used for developing Heimdall


Async/Await vs then()

Recommend using async/await when possible, and minimize promise chaining. Async/await makes JavaScript code more accessible to developers that aren't as familiar with JavaScript, and much easier to read.

Logic

The difference is that in an async function, JavaScript will pause the function execution until the promise settles. With .then(), the rest of the function will continue to execute but JavaScript won't execute the .then() callback until the promise settles.

If using promise chaining with .then(), we need to put any logic we want to execute after the request in the promise chain. Any code placed after fetch() will execute immediately, before the fetch() is done.

From a performance point of view, await is just an internal version of .then() (doing basically the same thing). The reason to choose one over the other doesn't really have to do with performance, but has to do with desired coding style or coding convenience.

References Top


Clone this wiki locally