I have one of the JS file where in multiple variables are declared in my node js App(deployed on dev). So, when first time the request is made the variables are used and values are kept getting changed during the run of the App. Like, say I have "count" variable declared(shown on UI) and the value is kept changing in one of the function for a period of 50 seconds. Within this 50 seconds, other person makes the request to the server and ideally, the second person who has made the request has to see a count value which is changing. But, due to the second request, the JS is getting loaded again and the variable is getting initialized back to 0. So, this is in turn affecting the first person who is viewing an App for which also it will show as 0.
Is there any way to initialize these variables only once? Also, thought about the using the exports by declaring all these variables in another JS and require it in current JS where all these variables are used since require will be called once if the JS is already loaded. However, I have huge number of variables and I will have to write multiple exports for each of the variables(not sure If my understanding is right here).
via Aak
No comments:
Post a Comment