eta icon indicating copy to clipboard operation
eta copied to clipboard

feat: adding globalAwait option

Open SilentVoid13 opened this issue 3 years ago • 5 comments

Implements feature of #99.

This feature allows us to add all data objects in an array and to await for it globally (only when the globalAwait option is set to true in the config).

This adds almost no overhead at runtime (adding a for loop to generate the array push, but that's neglectable overhead), because Promise.all just returns the value of synchronous functions and variables and only awaits for asynchronous functions. This could even be the default behavior when resolving templates (removing the option).

This allows us to speed things up a lot when having a lot of asynchronous functions in our data object.

Because this doesn't change anything about how this template engine works and just adds some extra speed, I don't think this is an out of scope feature, it is very useful when dealing with asynchronous functions.

SilentVoid13 avatar Apr 02 '21 11:04 SilentVoid13

Congratulations :tada:. DeepCode analyzed your code in 5.62 seconds and we found no issues. Enjoy a moment of no bugs :sunny:.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

ghost avatar Apr 02 '21 11:04 ghost

Sorry for taking so long, I will take a look at this today.

shadowtime2000 avatar Apr 05 '21 15:04 shadowtime2000

@shadowtime2000 This should be good !

SilentVoid13 avatar Apr 05 '21 23:04 SilentVoid13

Hey @shadowtime2000, sorry for the late response. I can't really think of a good way to test as I'm not familiar with unit tests in JS / TS. We're really just adding everything in an array and awaiting for it so I don't think we need any new fancy tests compared to the existing ones.

SilentVoid13 avatar Apr 13 '21 21:04 SilentVoid13

@SilentVoid13 Sorry for the late response.

Sorry, I am a little scared of merging something like this which is kind of hard to test so I am going to put this on hold I guess. Sorry again.

shadowtime2000 avatar Apr 17 '21 07:04 shadowtime2000

I'm going to close this as stale and because it's for Eta v2. I'd be open to accepting a pull request with this functionality for v3.

nebrelbug avatar Jun 13 '23 20:06 nebrelbug