I'm writing a code to perform a "watch" on some resource in an api : Considering my code :
function myObj(){
this.endpoint = "/example"; // my endpoint
this.interval = 500; // my watch interval
}
myObj.prototype.watch = function(){
console.log(this.endpoint); // returns "/example"
this.intervalId = setInterval(this.refresh, this.interval);
}
myObj.prototype.destroy= function(){
clearInterval(this.intervalId);
}
myObj.prototype.refresh = function(){
console.log(this.endpoint) // -> undefined ???
}