On Mon, Jul 9, 2012 at 5:07 AM, Roel van Dijk <[email protected]> wrote:

> On Mon, Jul 2, 2012 at 5:41 PM, Roel van Dijk <[email protected]> wrote:
> >
> > Does anyone here know what is going on? Why does the first request work,
> > but all following requests fail? How can the people object miss many
> > functions?
> >
>
> This turned out to be a timing issue. The getViewer() function is added tot
> osapi.people service object by a gadgets.util.registerOnLoadHandler. Our
> call to getViewer() also happens on page load, but apparently too early, so
> it happens before the function was added to osapi.people.
>
> I couldn't find a callback or event to use for the completion of the
> registered registerOnLoadHandler-s.
>

Roel, this is turning out to be a common problem (my opinion at least).
There are a lot of capabilities that internally use the onLoadHandler
mechanic that gadgets depend on but since there isn't a guaranteed order to
them being called you never know if things will be loaded right if your
gadgets triggers on that event as well.  At the end of the day however this
is a shindig issue, not a rave issue to solve.

>
> We've fixed this by explicitly checking for the existence of
> osapi.people.getViewer, and delaying our gadget's Javascript until the
> function exists.
>

Can you post how you went about doing this so other people can use it as
well?

>
> --
> Roel
>

Reply via email to