I have a service variable that is initialized :
service = new google.gdata.calendar.CalendarService('timeless');
This happens in a callback function. My problem is that I have other functions that rely on the service variable. If I call them too soon the variable is undefined and the script does nothing.
The main problem would be if the user would try to click on a button that calls one of these functions. How can I make the function wait? If I use a cutsom spinlock it would kill the browser.
I need some kind of pseudo-mutex or wait/sleep function. I don’t think that setTimeout would help.
Thanks.
Introduce a level of indirection: rather than having the onclick() code call such functions directly, have it place the call on a variable that initially contains a function that does nothing (or perhaps displays an error message, or otherwise handles the condition), then once
serviceis initialised gets the real function assigned to it: