Promises in custom code

3 posts, 0 answers
  1. Phil
    Phil avatar
    15 posts
    Member since:
    Oct 2012

    Posted 30 Jan 2015 Link to this post

    Is there a way to create promises from within cloud code?

    I'm working with sdk queries which return promises, but then I need to work with the data. This creates a big mess of callbacks in my functions mixed with the promises I'm getting from the sdk library. Ultimately, I've run into a timing issue which is a bear to figure out now!

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 03 Feb 2015 Link to this post

    Hello Phil,

    At the moment it is not possible to construct your own promises in the Cloud Code. We are evaluating the possibility to incorporate a library that will greatly facilitate the creation and execution of asynchronous logic in the cloud code layer.

    Regarding the large number of callbacks. At the moment you can declare your functions in the current scope and return a promise from them. Then, chain the promises until the task is resolved to avoid the use of callbacks. Please, find my answer to a similar question here.

    Let me know if I may be of any further assistance.

    Best regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 22 Jul 2015 Link to this post

    Hello,

    This is a quick announcement that you can now create your own promises in the Cloud Code for Data and Cloud Functions using the integrated RSVP library. In addition, the Underscore utility is also available for use in the Cloud Code.

    More information is available in the documentation article here.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top