This is a migrated thread and some comments may be shown as answers.

Promises in custom code

2 Answers 57 Views
Cloud Code
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Phil
Top achievements
Rank 1
Phil asked on 30 Jan 2015, 10:41 PM
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 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 03 Feb 2015, 03:56 PM
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.
 
0
Anton Dobrev
Telerik team
answered on 22 Jul 2015, 12:04 PM
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.
 
Tags
Cloud Code
Asked by
Phil
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Share this question
or