Update - Appcelerator Alloy Cloud Services Adapter Now Supports Promises - Clearly Innovative | Web and Mobile DevelopmentClearly Innovative | Web and Mobile Development
Keep a look out for updated video to show use of new adapter here in the Appcelerator Alloy Video Series

Quick Overview

We all have become accustom to using promises to avoid the callback hell so here we have an example of an ACS adapter that supports promises using the $q javascript library.

First you create your Alloy Appcelerator Cloud Services Models following the steps outlined in the Appcelerator Alloy Model Documentation

When you are done an object looks similar to this; notice how we defined the ACS class and the name of the associated collection to match the class. This is essential because it is how the ACS Sync Adapter can construct the appropriate REST API call to interact with the service

For Custom Objects, we can support them by providing the name of the custom object in the configuration setting property and then set the object_method. See example of a custom object called book

So now you can query your custom object like this

This approach is MUCH cleaner that the old callback approach, give it a try… the adapter still support both approaches.

Addition changes required to get application to function properly.

  • You will need to include the q javascript library in your project
  • You will need to update your alloy.js  file to support the models and collections returning the promise from the sync adapter, see line 12 and line 35 where we return the result from the sync adapter


The new changes to alloy.js

Click here for Complete Source Code Available here in GitHub Repository


Click here to see Clearly Innovative Inc: Beginning Appcelerator Alloy Video Series


Latest Video