I have a situation where I need to call the function callMe() every 1000 ms. While this setup is functioning as expected, I am encountering an issue when trying to call another function from within callMe(). The error message I am receiving is:
uncaught TypeError: this.sortTargets is not a function
Here is my class variable:
private intervalId : any;
The code and functions in question are:
constructor () {
this.intervalId = setInterval(this.checkLabelConflicts, 1000);
}
private sortTargets() {
console.log("hello world");
}
private checkFunction() {
this.sortTargets();
}
It seems that I am unable to call other functions from within the intervaled function. I have even tried rearranging the code, moving the constructor to the bottom, but it seems like there might be a declaration missing error. If anyone has a solution that does not involve setInterval (such as workers/threads), I would greatly appreciate the explanation.
Have a great Monday!