I’ve nodes program which I need to run two function in the beginning of the program And later on access the function results, currently with await each function at a time this works, However in order to save a time and not waiting to GetService and GetProcess as I need the data later on in the project It takes about 4 seconds to get this data and I want to run it on the background as I don’t need the results immediately, How I can do it in node js, If I run promise.all It would wait until the getService and getProcess and then go to rest of the program.
an example
function main() { //I want to run this both function in background to save time let service = await GetServices(); this.process = await GetProcess(); …..//Here additional code is running //let say that after 30 second this code is called Let users = GetUser(service); Let users = GetAdress(this.process); } im actually running yeoman generator https://yeoman.io/authoring/ https://yeoman.io/authoring/user-interactions.html
export default class myGenerator extends Generator { //here I want run those function in background to save time as the prompt to the user takes some time (lets say user have many questions...) async initializing() { let service = await GetServices(); this.process = await GetProcess(); } async prompting() { const answers = await this.prompt([ { type: "input", name: "name", message: "Your project name", default: this.appname // Default to current folder name }, { type: "confirm", name: "list", choises: this.process //here I need to data from the function running in background } ]); }