I have function like:
getNumber(value) {
    this.myService.getApi(value).subscribe(data => {
        this.myVariable = data;
    });
}
And I am calling that function in other function as follows :
set() {
    if (this.value == 1) {
        this.getNumber(firstNumber)
        this.newVariable = this.myVariable;
    } else {
        this.getNumber(secondNumber)
        this.newVariabe = this.myVariable + 1;
    }
};
this.value is getting from other function. The problem is that this.newVariable is empty. I'm sure this is because the subscribe hasn't finished before I try to access this.Variable
Is there any way to wait for the subscribe to finish before I do anything else?
 
     
    