I have 3 functions and one button. I want to press the button and call 3 function not at the same time, but one after another, so each function waits till another (previous function) is completed
I have a onPost, onGet and navigate function
What I would like to do ist to call a function allTogether
allTogether() {
this.onPost();
this.onGet();
this.navigate();
}
Here is my onPost Method, where I send data of current client to backend
onPost () {
const messageForDb = (JSON.stringify(this.model));
localStorage.setItem('userKey', messageForDb);
this._httpService.postJSON(this.model)
.subscribe(
data => this.postData = JSON.stringify(data),
error => alert(error),
);
}
Here is my onGet() and here I get information about my client, so I can use it later in third function navigation()
onGet() {
this._httpService.getCurrentState(this.model.user_email, this.model.client)
.subscribe(
// data => this.getData = JSON.stringify(data),
data => this.getData = data,
error => alert(error),
);
}
navigation () {
let part = json.message.part;
let num = json.message.number;
this.router.navigate(['part'], {queryParams: {'number': 'num'}});
}
I tried with subscribe, but failed...so how cloud I implements the function allTogether() else ? I tested all functions and they work separately, but all together..