Skip to content

Instantly share code, notes, and snippets.

@KellyRice
Created January 31, 2012 17:53
Show Gist options
  • Save KellyRice/1711851 to your computer and use it in GitHub Desktop.
Save KellyRice/1711851 to your computer and use it in GitHub Desktop.
Mark code 2
// User ID
var _id;
// Facebook ready
window.fbAsyncInit = function() {
FB.init({ appId: 'XXX' });
// Do we have a user?
FB.getLoginStatus(function(response) {
if('connected' === response.status) {
// Save user ID
_id = response.authResponse.userID;
// NOTE: nest all dependencies, not good for performance and readability
get('anotherLibrary.js', function() {
if(anotherLibrary.success) {
get('yetAnotherLibrary.js', function() {
if(yetAnotherLibrary.status) {
// Done, now get user from Kinvey
kinvey.user.fetch(_id, function(user) {
// User found, go ahead and render page
});
}
});
}
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment