Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been tasked to write a script which will run on the parse.com cloud ( https://parse.com/docs/cloud_code_guide[^] ) and update the parse-database as needed based on a 3rd party source (another website, that needs to be monitored). The only language supported on parse.com is javascript - something I'm not familiar with. To compound matters, a lot of the calls are asynchronous in nature.

Does anyone know any good material from where I can learn about asynchronous javascript for a server environment?

An issue I have with all the tutorials I've found, is that they assume that I'm working in a web-browser. That by itself is not an issue; the problem is that they all assume I have a good grasp of HTML and CSS. I don't and can't spare the time to study something irrelevant to my work.

For example, at one point, I was having issues with global variables and a suggestion was to define them all with "window". Like "var window.x = 3" or the like. But in the parse cloud, "window" doesn't even exist!

So ... help please?

-chronodekar
Posted

1 solution

 
Share this answer
 
Comments
chronodekar 11-Feb-14 11:22am    
Thanks for the reply Tadit. But sadly, I can't find much use in the links you provided. The first one, I'm more than familiar with. It's the javascript help on parse.com and I've been to that page more times than I can remember.

Link 2 is interesting, but the focus is for a client web-application. My situation is that I need to create a script, which runs as a background task on the parse.com servers. For example in synchronous pseudo-code I want to do this;

do {

call_http_REST_get_on_remote_site(); // async call
parse_current_batch_of_results();

} while (no_more_results_from_remote_site); // this can be decyphered from the reply we get in the first http-get call


The problem I'm facing is that if I try the above in parse-javascript, the call_http_REST_get_on_remote_site() operation is an asynchrous call. The server leaves it at that and proceeds to the next bit - basically running the do-while loop only once! But if it had waited, the results would have clearly shown that the loop needs to run a few more times.

Link 3 & 4 doesn't apply to me as I'm not making a web-app. This will ONLY be running on the server as a background task - no way will a user directly come in contact with it. ... or even indirectly for that matter.

Link 5 is a nice errata, but more than 2 years old.

-chronodekar
Can't you make it a sync call? Else, I would suggest you to research more on this by searching stuffs in Google.
chronodekar 12-Feb-14 1:18am    
I would *love* to make it a sync call, but the API doesn't support it. :(

-chronodekar
If the API, don't support that, then you can't do it.
However, you can ask in their support forums for this. They might give you some trick.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900