Saturday, June 15, 2013

Creating JavaScript List Repositories for the SharePoint REST API

I've recently been working on a project where I've been leveraging the SharePoint 2010 REST API. It is a great experience especially after moving from SharePoint 2007 client side development. I've been able to develop web parts that are 100% client driven with no reliance on any server side code other than the REST services that SharePoint already exposes.

As I began developing I quickly noticed that calls to jQuery ajax and getJSON functions were littering my code. Of course, these calls are completely necessary, but I wanted to find a way to reduce duplication, increase reuse, and create a better programming experience for the rest of the effort. I decided to take these calls and create a wrapper object that would be responsible for the plumbing of calling my lists. What I ended up with was an object very similar to a traditional repository used in other languages.