Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/angular-facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@
this.getSdkVersion = function() {
return settings.version;
};

/**
* Library Failure Timeout
*/
this.setFailureTimeout = function(value) {
settings.failureTimeout = value;
};

/**
* Init Facebook API required stuff
Expand Down Expand Up @@ -364,6 +371,8 @@
// Call when loadDeferred be resolved, meaning Service is ready to be used.
loadDeferred.promise.then(function() {
$window.FB[name].apply(FB, args);
}, function() {
d.reject('Facebook API failed to initialize');
});
});

Expand Down Expand Up @@ -554,6 +563,14 @@
document.getElementsByTagName('head')[0].appendChild(script);
})();
}

// Reject loadDeferred after a timeout
// If the library is loaded before the timeout, the reject won't affect as promises are resolved only once
if (settings.failureTimeout) {
$timeout(function() {
loadDeferred.reject();
}, settings.failureTimeout);
}
}
]);

Expand Down