Is there a correct or "better" way to handle this
is JavaScript classes with-in Promises (or Callbacks even)
Currently I have just getting around this by doing this
var self = this;
But this feels 'hackey' to me.
Ignore most of the code below, it's just to get my point across.
class thing {
drawthing(thing) {
console.log(thing);
}
updatethings(thing) {
var self = this; //a better way to do this
return new Promise(function (resolve) {
setTimeout(function(){
self.drawthing(thing);
return resolve(thing);
},2000);
});
}
}
var t = new thing();
t.updatethings('hello').then(console.log);