Last active
August 29, 2015 14:05
-
-
Save djsmith42/a834e6c75ff942f4e0e8 to your computer and use it in GitHub Desktop.
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
function getCurrentUser(callback) { | |
$http.get("/api/users/self/").then(function(user) { | |
callback(user); | |
}); | |
}); | |
function getCurrentUser() { | |
var deferred = $q.defer(); | |
$http.get("/api/users/self/").then(function(user) { | |
deferred.resolve(user); | |
}); | |
return deferred.promise; | |
} | |
$q.all([getCurrentUser(), getPermissions()]) | |
.then(function(responses) { | |
var user = response[0]; | |
var permissions = response[1]; | |
}); | |
return function(fulfilled) { | |
return function(array) { | |
fulfilled.apply(void 0, array); | |
} | |
} | |
if (!alreadyHaveUser && !alreadyHavePermissions) { | |
getCurrentUser(function(user) { | |
// Do something with user | |
}); | |
getPermissions(function(permissions) { | |
// Do something with permissions | |
}); | |
} else if (!alreadyHaveUser) { | |
getCurrentUser(function(user) { | |
// Do something with user | |
}); | |
} else if (!alreadyHavePermissions) { | |
getPermissions(function(permissions) { | |
// Do something with permissions | |
}); | |
} | |
// Do something with user and permissions??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment