###Async usage pattern
All query methods use the following typical async pattern
//
site.Badges().invoke(function onSuccess(items, userContext, methodName) {
// handle items array of domain objects
// if linq.js is loaded the items array will be an instance of
// Enumerable<domain object>
}, function onFailed(error, userContext, methodName) {
// handle error - which looks like this:
// error : {
// message: "the message",
// code: 500, // the status code
// url: "the url that failed"
// };
}, { someUserContext: "foo" });
//
The static ApiProxy provides a place to hang default/global handlers. Certain application structures lend themselves well to a centralized response handler.
// on Soapi.Net.ApiProxy, you may set default callbacks. e.g.
Soapi.Net.ApiProxy
.set_defaultSucceededCallback(function(data, userContext, methodName) {
// default response handler
});
Soapi.Net.ApiProxy
.set_defaultFailedCallback(function(error, userContext, methodName) {
// default error handler
});
Once you are comfortable with the async pattern used by Soapi.JS2, a clear understanding of query parameterization is in order.....
NEXT: Parameterization and PagingParameterization and Paging