This week, a teammate had to handle a strange phenomenon ๐ค occurring while using an Angular App.
I remind you that Angular uses an asynchronous mechanism.
So, when you use the Angular App, for example clicking ๐ฑ๏ธ the menu, an event is thrown ๐ , then proceeded later.
Most of the time, everything is fine ๐.
The heck is when you are app handle some events very quickly ๐จ and so occur before expected ๐ฎ.
So you may have a functional value of a previous call used instead of the one you are waiting for.
And you end with an incorrect โ GUI.
There are many ways ๐ก๐ก๐ก of dealing with such a setting.
But when you deal with ๐๐ซ๐จ๐ฆ๐ข๐ฌ๐ (https://lnkd.in/eJCwBNW2), you can just use the JS keyword ๐๐ฐ๐๐ข๐ญ before the call of your method returning a promise.
It will wait โฑ๏ธ for the promise to return its result. YAY! โบ๏ธ
An outstanding, tremendous, snazzy gift from JavaScript. ๐ช
It made my day! ๐ (I was investigating a complex fix with Angular change detection)
Example from stackoverflow:
#angular #tip #angularProgramming #await