in service, using http
data return promise.
i have function this
onclick(id:number){ this.myservice.getsomedata(id).then(response => this.myobject=response); //do myobject }
however, need wait service return data before can continue. cannot call service earlier because depends on option user clicked.
i thinking wrap in settimeout
onclick(id:number){ settimeout(() => { this.myservice.getsomedata(id).then(response => this.myobject=response); }, 1000); //do myobject }
but 1 second guess , might wasting time or not have enough time. there way pause function until service returns information, ideally timeout after 5 seconds (and if happens, have execute handling code)? during time, user should not able anything.
Comments
Post a Comment