Skip to content

Instantly share code, notes, and snippets.

@quicksnap
Created February 21, 2014 21:53
Show Gist options
  • Select an option

  • Save quicksnap/9144284 to your computer and use it in GitHub Desktop.

Select an option

Save quicksnap/9144284 to your computer and use it in GitHub Desktop.
(function () {
encrypt = function(arguments) {
newPromise = _getPublicKey();
newPromise.success(function(results) {
results.pubKey === 'Foobar'; // true
})
}
_getPublicKey = function() {
var httpPromise = $http.get('blah');
var deferred = $q.defer();
var newPromise = deferred.promise;
httpPromise.success(function(response) {
// Cache response
newPromise.resolve( { pubKey: 'Foobar' } );
});
return newPromise;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment