Open SteveDrakey opened 7 years ago
Using angular2-busy I lock the UI when a http request is running.
this.loginFail = !await (this.busy = this.authenticationService.login(this.username, this.password));
I only have one promise, if the promise fails to create ngBusy just keeps spinning, to make it fail I try to request from error:/ as follows :
error:/
async login(username: string, password: string): Promise < boolean > { try { var r = await this.reCaptchaHttp.post('error:/', { Email: username, password: password }).toPromise(); var JWTToken = r.json(); return true; } catch (e) { // snip. we have more code but its not relevent return false; } }
But, if I add
await this.delay(0);
It works fine.
And the delay code
async delay(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }
If I remove await this.delay(0); it never stops spinning.
If I debug the code, when it works busy looks like (note, I still have an exception in the case but its thrown by the server so the http request has completed although in error)
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: false, busyFulfilled: true}
When it fails ( error before http request )
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: false}
And with my delay
Using angular2-busy I lock the UI when a http request is running.
I only have one promise, if the promise fails to create ngBusy just keeps spinning, to make it fail I try to request from
error:/
as follows :But, if I add
It works fine.
And the delay code
If I remove
await this.delay(0);
it never stops spinning.If I debug the code, when it works busy looks like (note, I still have an exception in the case but its thrown by the server so the http request has completed although in error)
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: false, busyFulfilled: true}
When it fails ( error before http request )
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: false}
And with my delay
ZoneAwarePromise {__zone_symbol__state: true, __zone_symbol__value: false, busyFulfilled: true}