I am just getting started on converting some apps to the commonjs method, as well as writing a new one, and am starting to get the hang of it. However, my newest app will make use of ACS and I have a concern about API calls, as they are limited and I don't want to be wasteful.
On an old app of mine, I created a tableView window in one of my tabs as soon as the app loaded. I grabbed the rows from my server, and appended them to the tableview. Viola! it was done. I would not make another request to the server again UNLESS data was being changed (add/delete/update). Otherwise, the tableView would just stay how it was.
With commonJS, it seems that the window is being created every time it is viewed. So say I do a:
var tvWindow = new tableViewWindow();
and inside tableViewWindow.js, I create a tableview and get data for it from ACS...
That means EVERY time the user goes to this window, a tier 1 API call is used. Having never used ACS, I can't quite grasp how quickly those will be used up, but it seems like there would be a more efficient way.
Is there?
2 Answers
'That means EVERY time the user goes to this window, a tier 1 API call is used.'
Can you confirm that this is ACTUALLY the case? That there are multiple API calls being made?
With a new instantiation, this might be occurring as you are are creating a new object.
var tvWindow = tableViewWindow();
is not the same as
var tvWindow = new tableViewWindow();
Your tableView window can always be architected in a way such that it only retrieves data from the server when you want it to. There is nothing preventing you from caching the data that is a result of the API call
Your Answer
Think you can help? Login to answer this question!