Skip to main content
15-Moonstone
March 7, 2019
Solved

List of all throw events in Experience Lifecycle

  • March 7, 2019
  • 2 replies
  • 5809 views

Hello!

 

I am looking for a complete list of all thrown events in Experience Lifecycle. I know that we can use

$scope.$on('eventName', callback);

To catch specific events and do some stuff with that. For example we know that we can subscribe to:

modelLoaded
trackingacquired

Can someone help me to build this list?

 

Thanks!

Adam

Best answer by RolandRaytchev

Hi @A_Macierzynski ,

 

unfortunately I also will be also  happy to have a complete list but so far I also do not have information about such list.

Therefore for the first time I want to provide additionally some events I know (better as nothing  Man Happy 😞

1.) modelLoaded - is not required any more because the UI allow directly to specify this event.

...
$rootScope.$on('modelLoaded', function() {
 //do some code here
 } )
....

2.) Step completed example:

scope.$on('stepcompleted', function(evt, arg1, arg2, arg3) { 
 var parsedArg3 = JSON.parse(arg3);
console.log("stepcompleted stepNumber="+parsedArg3.stepNumber + " nextStep="+parsedArg3.nextStep);
 
$scope.app.stepNumber=parseInt(parsedArg3.stepNumber);
$scope.app.nextStep=parseInt(parsedArg3.nextStep);
$scope.app.duration=parseFloat(parsedArg3.duration);
 
}); 

3.) step started:

...
$scope.$on('stepstarted', function(evt, arg1, arg2, arg3) { 
 var parsedArg3 = JSON.parse(arg3); 
 console.warn(arg3); 

 console.log("stepstarted stepNumber="+parsedArg3.stepNumber);
 $scope.app.stepNumber=parseInt(parsedArg3.stepNumber);
$scope.app.nextStep=parseInt(parsedArg3.nextStep);
$scope.app.duration=parseFloat(parsedArg3.duration);
 
});
... 

Please, pay attention that on some platforms not all information is available in stepstarted. So, In this case the complete info is in step completed – the best is to test it.

4.) after you enter a view in studio (e.g. Home ...)

...
$scope.$on('$ionicView.afterEnter', function() {$scope.populateModelList();
 });
...

5.) click/tap event on the current panel:

...
$rootScope.$on('click', function() { tapCount++;console.log("click event called");} );
...

or  with coordinates

...
document.addEventListener('click', function(event) {console.log("click() 1 called");
 $scope.lastClick = {
 x: event.pageX, y: event.pageY};
});
...

you can also see this topic.

 

 

2 replies

21-Topaz I
March 11, 2019

Hi @A_Macierzynski ,

 

unfortunately I also will be also  happy to have a complete list but so far I also do not have information about such list.

Therefore for the first time I want to provide additionally some events I know (better as nothing  Man Happy 😞

1.) modelLoaded - is not required any more because the UI allow directly to specify this event.

...
$rootScope.$on('modelLoaded', function() {
 //do some code here
 } )
....

2.) Step completed example:

scope.$on('stepcompleted', function(evt, arg1, arg2, arg3) { 
 var parsedArg3 = JSON.parse(arg3);
console.log("stepcompleted stepNumber="+parsedArg3.stepNumber + " nextStep="+parsedArg3.nextStep);
 
$scope.app.stepNumber=parseInt(parsedArg3.stepNumber);
$scope.app.nextStep=parseInt(parsedArg3.nextStep);
$scope.app.duration=parseFloat(parsedArg3.duration);
 
}); 

3.) step started:

...
$scope.$on('stepstarted', function(evt, arg1, arg2, arg3) { 
 var parsedArg3 = JSON.parse(arg3); 
 console.warn(arg3); 

 console.log("stepstarted stepNumber="+parsedArg3.stepNumber);
 $scope.app.stepNumber=parseInt(parsedArg3.stepNumber);
$scope.app.nextStep=parseInt(parsedArg3.nextStep);
$scope.app.duration=parseFloat(parsedArg3.duration);
 
});
... 

Please, pay attention that on some platforms not all information is available in stepstarted. So, In this case the complete info is in step completed – the best is to test it.

4.) after you enter a view in studio (e.g. Home ...)

...
$scope.$on('$ionicView.afterEnter', function() {$scope.populateModelList();
 });
...

5.) click/tap event on the current panel:

...
$rootScope.$on('click', function() { tapCount++;console.log("click event called");} );
...

or  with coordinates

...
document.addEventListener('click', function(event) {console.log("click() 1 called");
 $scope.lastClick = {
 x: event.pageX, y: event.pageY};
});
...

you can also see this topic.

 

 

16-Pearl
March 11, 2019

Thanks so much! This is gold!

21-Topaz I
March 11, 2019

Hi @whity, your are wellcome.

so the next event ... ( I will try to document here the next time  all envents I will find in my projects)

 

6.) New step  -example:

...
$scope.$on('newStep', function(evt,arg) {
 var getStepRegex = /\((\d*)\//; 
 console.log(arg);
 console.log( getStepRegex.exec(arg)[1]);
//check what it prints to the console - the step number }); ...

 7.) Here a more advance construct- defines a userpick event for all models widgets

 angular.forEach($element.find('twx-dt-model'), function(value, key) {
 // search all twx-td-model's -> means all model widgets
 angular.element(value).scope().$on('userpick',function(event,target,parent,edata) {
 //for each model widget will set a userpick listener 
 console.log('edata');console.warn(edata);
	 console.log("JSON.parse(edata)");console.warn(JSON.parse(edata)); 
 	 	var pathid = JSON.parse(edata).occurrence;
	 $scope.currentSelection = target + "-" + pathid;
// this is the current selection - the selected component occurence
// you can use it for example as shown below
// try{
//tml3dRenderer.GetObject($scope.currentSelection).GetWidget().ApplyOccludeOpacity(OCLUDE_VAL,OPACITY_VAL);
//} catch (e1234) {$scope.view.wdg['3DLabel-4']['text']= "e 1234exception in GetObject.GetWidget..."; }
// } ) //end of the userpick defintion } ) //end of for each funciton

 8.) tracking event:

 

...
$scope.$on('trackingacquired', function (evt,arg) {
 // alert('didStartTracking'); 
 // this is not really needed
 $scope.message = parseInt($scope.app.params["currentStep"]);
 
 $scope.$apply();
});

$scope.$on('trackinglost', function (evt,arg) {
 // alert('didFinishTracking'); 
 
 $scope.message = "Scan the ThingCode with your camera.";
 
 $scope.$apply();
});
....

9.popover event:

 

 

// 
var my_tmp = '<ion-popover-view><ion-header-bar> <h1 class="title">My Popover Title</h1> </ion-header-bar> <ion-content> My message here! </ion-content></ion-popoverview>';
$scope.popover= $ionicPopover.fromTemplate(my_tmp, { scope: $scope });

$ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }).then(function(popover) { $scope.popover= popover; });
$scope.openPopover= function($event) { $scope.popover.show($event); }; $scope.closePopover= function() { $scope.popover.hide(); }
//////////////destroy popover
 $scope.$on('$destroy', function() { $scope.popover.remove(); }); 
/////// hide popover 
$scope.$on('popover.hidden', function() { // your hide action..
 });
 // on remove popover 
$scope.$on('popover.removed', function() { // your remove action
 }); });

10) watch event -watches are created using the $scope.$watch() function. When you register a watch you pass two functions as parameters to the $watch() function: 1)A value function 2)A listener function 

 

When the value returned by fnk 1.) changes - this lead to execution of the funciton 2.)

Example:

 

...
$scope.$watch(function(scope) { return $scope.view.wdg['label-1']['text'] },
// watches if change for the the text of label-1
//when changes then play a step for model-1
	function() {
 	console.log($scope.view.wdg["model-1"]);
 		$scope.view.wdg["model-1"].svc.play;
		 
	}
);
...

11.) Camera tracking - make sense only on mobile device- no sense for preview mode!

//// define tracingEvent only on end device
tml3dRenderer.setupTrackingEventsCommand (function(target,eyepos,eyedir,eyeup) { 
 // $scope.view.wdg['3DLabel-1']['text']="eyepos=("+eyepos[0].toFixed(2)+","+eyepos[1].toFixed(2)+","+eyepos[2].toFixed(2)+")";
 $scope.app.params['target']=target;
 
 $scope.app.params['eyepos']="eyepos=("+eyepos[0].toFixed(2)+","+eyepos[1].toFixed(2)+","+eyepos[2].toFixed(2)+")";
 $scope.app.params['eyedir']="eyedir=("+eyedir[0].toFixed(2)+","+eyedir[1].toFixed(2)+","+eyedir[2].toFixed(2)+")";
 $scope.app.params['eyeup'] ="eyeup =("+ eyeup[0].toFixed(2)+","+ eyeup[1].toFixed(2)+","+ eyeup[2].toFixed(2)+")";
 
 /////////////////////

},undefined); 
//// define tracingEvent only on end device
 } //end device

 

 

 

 

15-Moonstone
March 20, 2019

Hi @RolandRaytchev 

 

That's exactly what I was looking for!

Great job!