I have the following code. After call back is finished, I want to set the boolean to true but it fails with "undefined".
const processor = Processor.createInstance();
class Person {
private status = {
failed: true
}
processInfo(){
processor.process(function(d){
//do stuff now then set stays to false
this.status.failed = false; //fails with "failed" of undefined.
});
}
}
Attempted solutions:
create a function that sets status.failed to true then pass the function as a parameter to the processInfo() method and call it:
function setStatus(status) { this.status.failed = status; }
processInfo(statusUpdater){ processor.process(function(d){ //do stuff now then set stays to false statusUpdater(false); });
}
still it fails with the same error message.
2nd: pass status object as a parameter to processInfo. It does work but not sure why or if it is the right way.