I'm facing an issue with my simple class
class A{
constructor(){
this.loadComponents().then(function(values) {callbackOnLoad();});
}
callbackOnLoad(){
//do some things
}
loadComponents(){
...
return Promise.all([p1,p2,p3,p4,p5,p6,p7,p8]);
}
}
I need help solving a problem where I can't call callbackOnLoad after all promises are fulfilled. I understand that "this" depends on the caller, causing callbackOnLoad not to work as expected. How should I structure or design my code to overcome this obstacle?