cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript async functionality execute code step-by-step

KanivetsAV
5-Regular Member

Javascript async functionality execute code step-by-step

Hello everybody!

 

Is there a way to sequentially execute javascript code in vuforia?

 

I have a function in which I need to perform a series of actions in a clear order:
1) Call the service and get the data
2) Analyze data from the service
3) Depending on the data analysis, show or hide some elements of the vuforia interface

 

If i write the code like this:

 

// Call service
$scope.ServiceCall = function () {
     twx.app.fn.triggerDataService("VuforiaThing", "Service");
};

// Anylaze data
$scope.DataAnalyze = function () {
     if ($scope.app.mdl['VuforiaThing'].svc['Service'].data.current['OperationStatus'] == "status"){
         $scope.app.params.testparam = true;
     } else {
         $scope.app.params.testparam = false;
     }
};

//Manipulate UI
$scope.ManipulateUI = function () {
     if ($scope.app.params.testparam == "true"){
         $scope.view.wdg['WidgetID']['visible'] = true;
     } else {
         $scope.view.wdg['WidgetID']['visible'] = false;
     }
};

// Execute code after  view entry
$scope.$on('$ionicView.afterEnter', function() {
     $scope.ServiceCall();
     $scope.DataAnalyze();
     $scope.ManipulateUI();
});

 

 

sometimes it turns out that step 2 is performed earlier than 1 and then an incorrect analysis occurs, since there is no data and, accordingly, at step 3, I perform erroneous actions on the interface elements.

 

If i try to use "async function" vuforia say

 

 

! 'async function' is only available in ES8 (use 'esversion: 8').

 

 

I find some solutions like this

2021-05-13 181547.png2021-05-13 181724.png

but it does not working in Vuforia.

 

1 REPLY 1

Have you tried to listen on serviceInvokeComplete?

Like this example.

 

$scope.$on('getModelURL.serviceInvokeComplete', function() {

$scope.view.wdg['model-4']['src'] = $scope.app.mdl['remoteDesignShareUtils'].svc['getModelURL'].data.current['result'];

$scope.app.mdl['remoteDesignShareUtils'].svc['copyRep2FileRepowJSON'].data.current['result'];*/

});

Announcements

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection