Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse.get synchronous #16

Open
arvindstutzen opened this issue Feb 2, 2014 · 3 comments
Open

parse.get synchronous #16

arvindstutzen opened this issue Feb 2, 2014 · 3 comments

Comments

@arvindstutzen
Copy link

Is it possible have parse.get function as synchronous one ?

@srhyne
Copy link
Owner

srhyne commented Feb 3, 2014

Right now, there is no way to override the $.ajax request object through parse.get. However, parse.get does return the $.Deferred object from $.ajax. So I would suggest just using

var req = $.parse.get('Class');
 req.done(doSomethig);
 req.done(doAnotherThing)

You could make a really easy step system like this..

  var step = function(cb){
    req.done(cb);
};

Also, take a look at how Jasmine does runs, waitsFor, runs. This is a great way of handling synchronous/async behavior.

What are you trying to build? Would love to give advice if needed. Be well.

@abusu-noggin
Copy link

Hi There,
I've tried to do just that
var req = $.parse.get('Class'); req.done(doSomethig); req.done(doAnotherThing)

It keeps telling me that done() is undefined.
So I thought maybe my jQ library was old but even complete() doesn't work.

Any ideas?

@srhyne
Copy link
Owner

srhyne commented Mar 27, 2015

@abusu-noggin I'm sorry, I was mistaken. The $.parse.get does not return a $.Deferred object. It just returns $.parse. Instead you need to pase $.parse.get('Class', callback, error)

However, here's a nice wrapper for a getting a promise for a get request.

$.parse.getPromise = function(class){
  var dfd;

    $.parse.get(class, function(data){
       dfd.resolve(data);
    }, function(data){
       dfd.reject(data);
    });

    return dfd;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants