Question

I have an app built with angular angular stateprovider/phonegap and ionic with the ionic seed. I do make REST requests to a server to receive data needed in my views. Every request needs a control token which is encrypted with aes. So generally: I want to do the encryption asynchronous so the ui won't block (the encryption takes on some mobile devices up to eight seconds, which results to a ui-freeze or long loading time after app startup). Timeout is not an option for me because I don't know how long the encryption takes on a specific device.

An option would be using web workers (But I don't think older devices are supporting this... )

I also tried $scope.$evalAsync(), but this is executed at any time...

What do you think about solving that problem?

Greetings. P.S: the part of my controller for the view (the encryption is made where the $resource.query() is triggered):

    $scope.resource = {};
    $scope.loadProjects = function(){
    $scope.resource.projects = RProject.query();
    $scope.resource.projects.$promise.then(function(data){

        for(var i = 0; i < data.length; i++)
            //create project title mapping model for item project id
            $scope.view.projectTitleListMap[data[i].project_id] = data[i].project_title;

    });

};

$scope.$evalAsync($scope.loadProjects());
Était-ce utile?

La solution

Unfortunately, there is no such thing as concurrent threads in javascript.

So you will either have to augment your aes-code with trivial timeouts to allow handling of the event queue, or use web workers.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top