Add an Angular Loading Spinner with RxJS and Material

  Рет қаралды 18,578

Zoaib Khan

Zoaib Khan

Күн бұрын

Пікірлер: 41
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
Hey guys! Check out the follow up video to this tutorial on the link below. I cover some improvements especially related to making multiple calls and their issues with the spinner kzbin.info/www/bejne/imnXd4ZsqZili9k
@TheFilburt88
@TheFilburt88 2 жыл бұрын
This is one of the best tutorials I've seen so far, you explained it very well. Thank you so Much!
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
You're very welcome, Franco! Glad it has helped in some way :)
@karthiksadanand5578
@karthiksadanand5578 3 жыл бұрын
This is one of the cleanest tutorials !, thank you
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Thanks Karthik, glad you liked it!
@emmanuellatrustenomah532
@emmanuellatrustenomah532 Жыл бұрын
This was very helpful!
@ZoaibKhan
@ZoaibKhan Жыл бұрын
Glad you liked it! 👍
@codeaz5673
@codeaz5673 Ай бұрын
thank u Sir. Can u make a video for upgrading this project angular v 19 please
@MariaBadanina
@MariaBadanina 9 ай бұрын
Thank you very much! This video helped me
@ZoaibKhan
@ZoaibKhan 9 ай бұрын
Glad you liked it!
@kiendinhkhoi
@kiendinhkhoi 3 жыл бұрын
How to show spinner and blur background bro?
@plumemotorpartpmp1625
@plumemotorpartpmp1625 2 жыл бұрын
thank you teacher very good lesson : )
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
You're welcome :)
@alexou857
@alexou857 2 жыл бұрын
Thank you my man, you are the best :)
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
You're welcome. Glad you liked it :)
@raviteja8798
@raviteja8798 2 жыл бұрын
Hello sir, I have one doubt regarding this. please help me sir, please reply
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
What kind of doubt, jhon?
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
@@raviteja8798 here's the follow up video to this tutorial which covers and fixes this issue. Hope it helps! :) kzbin.info/www/bejne/imnXd4ZsqZili9k
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
@@raviteja8798 ok, let me go through your problem in detail and see what the issue might be
@ZoaibKhan
@ZoaibKhan 2 жыл бұрын
@@raviteja8798 Hey! So after going your message in detail, it seems your problem is with the long-running API call on Component A. Ideally, you should add a way for the API call to be cancelled once the user navigates away from the component - because it's no longer needed. Here's a link for a possible solution: www.freakyjolly.com/angular-how-to-cancel-http-calls-on-router-change/ If you do need the data from the API call - then maybe you should use a global service with another behavior subject and load it there and add an exception in the interceptor - where the spinner doesn't show for this specific call. I'd suggest though to review this 1 minute long API call - because it would be pretty bad for user experience, besides creating this spinner problem... Hope this helps.
@vuduyanh7791
@vuduyanh7791 3 жыл бұрын
thank you so much , if settimeout for loading Spinner , what i do , please support
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
You're welcome, Vu! Can you describe in more detail, why do you want the settimeout for the loading spinner?
@vuduyanh7791
@vuduyanh7791 3 жыл бұрын
@@ZoaibKhan tks your , i do it success , However , I'm getting an error NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.. your can help me .
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Yes, this just appears in development and does not really affect the functionality much. But still, you can make a small change in the service on this line: loading$ = this._loading.asObservable().pipe(delay(1)); This is similar to setTimeout - using the RxJS delay operator instead because it looked cleaner to me. This should clear the error in development.
@vuduyanh7791
@vuduyanh7791 3 жыл бұрын
@@ZoaibKhan thanks your so much
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
@@vuduyanh7791 you're welcome :)
@gradientO
@gradientO 3 жыл бұрын
Good tutorial
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Thanks!
@amalrajp83
@amalrajp83 3 жыл бұрын
Hi Useful video👍. One qn , Will this work properly if multiple calls are done at same time?
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Hey Amal! Good question :) The answer is no. To allow multiple calls at same time, we'll need to increment and decrement a counter on start and end of API calls in the interceptor. Then, only hide the spinner when counter is 0 i.e. no calls are in process. Hope that helps
@amalrajp83
@amalrajp83 3 жыл бұрын
@@ZoaibKhan Thanks for the repy
@giorgimerabishvili8194
@giorgimerabishvili8194 3 жыл бұрын
Thank you!
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Welcome, Giorgi!
@tranquillityEnthusiast
@tranquillityEnthusiast 3 жыл бұрын
Need more vedios..
@JamesMooreDev
@JamesMooreDev 3 жыл бұрын
I get the following error message. NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.. This is something to do with the loading$ variable in my app.component.html. Just wondering if anyone knows a fix for this.
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Hey James! It is a development time error only and the quickest fix for it will be to add a small delay so that the the loading value is updated in the next change detection cycle. If you look at the latest code (link in description), I've already fixed that there. Hope that helps!
@ogunkayodeoluwaseun9348
@ogunkayodeoluwaseun9348 Жыл бұрын
@@ZoaibKhan how does one add this delay??? cause I'm facing the same error
@ZoaibKhan
@ZoaibKhan Жыл бұрын
@@ogunkayodeoluwaseun9348 Check out the code in the description!
@AGGPEE
@AGGPEE 2 жыл бұрын
Oh me vengoooo
@rohitsoni2439
@rohitsoni2439 3 жыл бұрын
Those who are facing error expression changed please add this : public readonly loading$ = this._loading.asObservable().pipe(delay(1));
@ZoaibKhan
@ZoaibKhan 3 жыл бұрын
Thanks for the public service message Rohit!
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН
Hot vs Cold Observable in RxJs (2021)
15:06
Decoded Frontend
Рет қаралды 28 М.
New Angular Material Docs make styling components a LOT easier!
15:52
The hidden gotcha with async in Angular forms
10:37
Joshua Morony
Рет қаралды 18 М.
Loading indicator done right | Angular Tips and Tricks
17:51
Code With Gio
Рет қаралды 7 М.
RxJS in Angular: Terms, Tips, and Patterns
43:01
Deborah Kurata
Рет қаралды 35 М.
How to share your RxJS observables for improved performance
10:24
Joshua Morony
Рет қаралды 24 М.
What I learned from this crazy RxJS stream in my Angular app
25:31
Joshua Morony
Рет қаралды 22 М.
Angular Loading Indicators Simplified | Step by Step Guide 2025
19:37