Skip to main content
1-Visitor
November 18, 2020
Question

Auto-refresh associate with function

  • November 18, 2020
  • 1 reply
  • 1055 views

Hello Ptc community,

I created a model and some javascript logic to show an image when a certain property is updated on a thing (on thingworx side). I would like if it is possible to associate a javascript function when a thing property auto refreshes.

Thanks a lot,
Frederico Silva

1 reply

21-Topaz I
December 4, 2020

@FredSilva92 ,

in case that your question is how to start some function when a value in TWX change - you can use:

.1) pay attention that the property will update in the Vuforia Experience project  and has binding to an app parameter:

2020-12-04_15-45-56.jpg

2.) use a watch block to watch  the change of the app parameter:

//what the app parameter prop1
$scope.$watch('app.params.prop1', function (newValue, oldValue, scope) {
console.log("Old Value -befor it was changed =" + oldValue); 
//! it could be undefined first time called
console.log("new Value -after it was changed =" + newValue); 
//prints the current $scope (copy) object passed to the $watch construct
// pay attention that in this context it has no $ ! e.g. console.warn(scope);

//call your function / action which should do some tasks for 
// the change of the prop1 app parameter 
})