Convert SharePoint JSOM's ExecuteQueryAsync to Promise in the Prototype
Today's blog is about adding an additional method to SharePoint JavaScript Object Model (JSOM)'s ClientContext object, so we can use it directly like a promise.
I call it "executeQuery" (instead of executeQueryAsync)
Wrapper with jQuery's $.Deferred
Wrapper with AngularJS's $q
How do you use this?
This may seem to be just small syntactic sugar, but now you have JSOM returning a promise that you can chain, loop, combine and juggle to your heart's content!
Remember, jQuery.ajax, SPServices, AngularJS, and now JSOM all returns promise objects now.