Skip to content

Instantly share code, notes, and snippets.

@eirikb

eirikb/app.js Secret

Created June 1, 2015 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikb/ab606207993f3e8af264 to your computer and use it in GitHub Desktop.
Save eirikb/ab606207993f3e8af264 to your computer and use it in GitHub Desktop.
ctx.exec
app.factory('ctx', function () {
return function () {
var ctx = SP.ClientContext.get_current();
ctx.exec = (function () {
var q;
return function () {
if (!q) {
q = $q.when().then(function () {
return $q(function (resolve, reject) {
ctx.executeQueryAsync(resolve, reject);
}).then(function () {
q = null;
});
});
}
return q;
};
})();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment