setTimeout causes error?

5 posts, 0 answers
  1. benallfree
    benallfree avatar
    3 posts
    Member since:
    Oct 2014

    Posted 06 Oct 2014 Link to this post

    I was writing some Content Type event responders and noticed that any use of setTimeout causes a nonspecific error message. 

    Is setTimeout not supported?
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 07 Oct 2014 Link to this post

    Hi Ben,

    You can use setTimeout as in any other JavaScript environment. For example:
    var data = everlive.data('MyData');
     
    setTimeout(function() {
        data.get().then(function(data) {
            console.log(data.result);
        }, function(err) {
            console.log(err);
        });
    }, 5000);


    If the problem persists could you share the code that raises the error so that we can investigate it on our side?

    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 07 Oct 2014 Link to this post

    Hi,

    Just a quick follow-up.

    In case you'd like to use setTimeout in the Cloud Code events and functions, I am afraid that this is not supported.

    Let me know if you have questions.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  4. benallfree
    benallfree avatar
    3 posts
    Member since:
    Oct 2014

    Posted 07 Oct 2014 in reply to Anton Dobrev Link to this post

    Yes, that was the question. Cloud Code. Is there a reason why setTimeout isn't supported? Or is there a list of things not supported in Cloud Code? 
  5. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 07 Oct 2014 Link to this post

    Hello,

    The execution of the cloud code events is time-limited thus maintaining a time-dependent code is not applicable in the Cloud Code. This would be the main reason that setTimeout, setInterval, etc., are not supported.

    We have on our roadmap a functionality for scheduling cloud functions which will cover apps that require time-dependent scenarios.

    The Cloud Code has its own API that you can explore here. Since this is a server logic layer, the API does not cover a lot of common JS functions like these mentioned above. Also, the context of the this keyword is limited.

    You are welcome to share your suggestions or feedback.

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