yeah I've go that, the dependent code is in _handleData()

The problem is more than that. consider the following:

var Spiral = Class.create({
        data:null,
        initialize: function()
        {
                var req = opensocial.newDataRequest();
                req.add(req.newFetchPersonRequest("VIEWER"),
'viewer');

                req.send(this._handleData.bindAsEventListener(this));
                alert('send is done');
        },

        _handleData: function(data)
        {
                this.data = data;
                alert('data received');
        },

})


this will alert in the following order:
'send is done'
'data received'

and an even bigger problem, I don't know how to tell when the send is
finished so that I can alert the rest of my code. Also, if the
callback function is an optional parameter, is there a different way
to get the data? Will send return the data so that I can make it run
line by line?

-James

On Feb 7, 6:03 pm, Jason <[EMAIL PROTECTED]> wrote:
> Hi James.
>
> The opensocial.DataRequest.send() method accepts an optional parameter
> -- a function object which should be invoked when the response is
> received. In your case, _handleData() is executed when viewer
> information is available. So place any dependent code in
> _handleRequest (or a function that is called from _handleRequest) and
> this should work.
>
> Please let me know if this helps or if there's something I missed.
>
> - Jason
>
> On Feb 6, 12:23 pm, James Murray <[EMAIL PROTECTED]> wrote:
>
> > I'm using prototype 1.6 in my project, Just so you know.
>
> > so i have this JS class that looks like this:
>
> > var Spiral = Class.create({
> >         data:null,
> >         initialize: function()
> >         {
> >                 var req = opensocial.newDataRequest();
> >                 req.add(req.newFetchPersonRequest("VIEWER"), 'viewer');
>
> >                 req.send(this._handleData.bindAsEventListener(this));
> >         },
>
> >         _handleData: function(data)
> >         {
> >                 this.data = data;
> >         },
>
> > })
>
> > then I instance it:
>
> > var spiral = new Spiral();
>
> > well I'm having problems with the fact that the DataRequest is
> > asynchronous, I need to know when the DataRequest is done so i can
> > continue to do what I plan on doing with the data.
>
> > After the line that instances the Spiral class runs, the DataRequest
> > is still going, if I try to operate on the data after I instance my
> > class I will most defiantly receive an error.
>
> > How can I either make it synchronous, or check that the DataRequest is
> > finished?
>
> > Any help is appreciated
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenSocial API Definition" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to