Skip to content

Commit

Permalink
Updated angular-facebook.js
Browse files Browse the repository at this point in the history
Wrapped fbAsyncInit stuff in $timeout for sake of things being called on
same time.
  • Loading branch information
luiscarlosjayk committed Dec 1, 2013
1 parent 8e72bf1 commit dffa807
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions lib/angular-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,35 +476,37 @@ provides: [facebook]

// Set ready global flag
flags.ready = true;
});


/**
* Subscribe to Facebook API events and broadcast through app.
*/
angular.forEach({
'auth.login': 'login',
'auth.logout': 'logout',
'auth.prompt': 'prompt',
'auth.sessionChange': 'sessionChange',
'auth.statusChange': 'statusChange',
'auth.authResponseChange': 'authResponseChange',
'xfbml.render': 'xfbmlRender',
'edge.create': 'like',
'edge.remove': 'unlike',
'comment.create': 'comment',
'comment.remove': 'uncomment'
}, function(mapped, name) {
FB.Event.subscribe(name, function(response) {
$timeout(function() {
$rootScope.$broadcast('Facebook:' + mapped, response);
/**
* Subscribe to Facebook API events and broadcast through app.
*/
angular.forEach({
'auth.login': 'login',
'auth.logout': 'logout',
'auth.prompt': 'prompt',
'auth.sessionChange': 'sessionChange',
'auth.statusChange': 'statusChange',
'auth.authResponseChange': 'authResponseChange',
'xfbml.render': 'xfbmlRender',
'edge.create': 'like',
'edge.remove': 'unlike',
'comment.create': 'comment',
'comment.remove': 'uncomment'
}, function(mapped, name) {
FB.Event.subscribe(name, function(response) {
$timeout(function() {
$rootScope.$broadcast('Facebook:' + mapped, response);
});
});
});
});

// Broadcast Facebook:load event
$rootScope.$broadcast('Facebook:load');
// Broadcast Facebook:load event
$rootScope.$broadcast('Facebook:load');

loadDeferred.resolve(FB);
loadDeferred.resolve(FB);

});
};

/**
Expand Down

0 comments on commit dffa807

Please sign in to comment.