Reputation: 2832
I have two applications (one in C++, the other one in node-webkit) that communicate via OSC. When I press +
a value will increment and when I press -
that value will decrement. The output is sent to the node-webkit instance and then handles the message using:
$scope.$on('FooBar', function (event, obj) {
//stuff happens here
};
In this case, obj
has one property, foobar
, a positive integer, that goes up and down everytime I press the keys.
Thing is I need to change the corresponding local value of FooBar. I tried using:
var aux = obj.foobar;
if (aux < obj.foobar) {
FooBarManager.raiseFooBar();
} else {
if (aux > obj.foobar) {
FooBarManager.lowerFooBar();
}
}
but I can't get the logic working. Nothing happens since aux
will always be equal to the property of obj
when a key is pressed and the value is changed.
Upvotes: 0
Views: 90
Reputation: 5337
Does this work then?
var previousFooBar = 0; // whatever your default is
$scope.$on('FooBar', function (event, obj) {
if (obj.foobar > previousFooBar) {
FooBarManager.raiseFooBar();
} else if (obj.foobar < previousFooBar) {
FooBarManager.lowerFooBar();
}
previousFooBar = obj.foobar;
});
Upvotes: 1