I have the following functions that I'm trying to call from a .then()
public waitFunction(): any {
setTimeout(function() {
this.getMap1();
}, 1000);
return;
}
public getMap1(): any {
this.autoSchemaRecords = null;
this._clientFileMappingService.getAllById(this._clientFileId).subscribe(
r => {
this.autoSchemaRecords = r;
},
e => {
this.showLoader = false;
throw e;
},
() => {
this.showLoader = false;
}
);
return;
}
When I try to call the waitFunction()
from the .then()
below I get the following error:
this.getMap1 is not a function
const result = this._clientFileMappingService
.fileUpload(autoSchema, this._clientFileId)
.then(this.hideModal(), this.waitFunction())
.catch(err => {
throw err;
});
This is confusing me because everything but the services are in the same component.
I am currently using a promise in my .fileUpload method for various reasons. If that function was an observable, I don't think I would be having this issue. However, I can't change it at this time.
Can anyone lead me in the right direction to be able to wait 1 second to repopulate autoSchemeaRecords collection?