Created
January 31, 2012 17:55
-
-
Save KellyRice/1711856 to your computer and use it in GitHub Desktop.
Mark code 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User ID | |
var _id; | |
// Handler to be executed when all dependencies are done | |
document.addEventListener('appready', function() { | |
kinvey.user.fetch(_id, function(user) { | |
// User found, go ahead and render page | |
}); | |
}, false); | |
// Dependency handlers | |
var dep = []; | |
var depDone = (function() { | |
var i = 0;//# dependencies | |
return function() { | |
i += 1; | |
if(dep.length === i) {//all dependencies are done | |
document.dispatchEvent('appready'); | |
} | |
}; | |
}()), | |
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; | |
// Notify that we're done | |
depDone(); | |
} | |
}); | |
}; | |
dep.push(window.fbAsyncInit); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment