I find myself writing a lot of code like this;
if(cond){
/*do some network call */
this.networkService.invoke(params).subscribe((res) => {
this.doSomething();
})
}else{
/* do something without calling the network */
this.doSomething();
}
Essentially, this.doSomething(); has to be called whether the condition is met or not. If the cond === true, then do some network call, then this.doSomething(). Is there a better way to write such code?
Aucun commentaire:
Enregistrer un commentaire