HTTP Interceptor + Material Progress Loader | The best use case explained in Angular | Service calls

  Рет қаралды 55,857

Shaheer Shukur

Shaheer Shukur

Күн бұрын

Пікірлер: 92
3 жыл бұрын
The best angular video thar I've ever seen!! Watching all them...
@shaheershukur
@shaheershukur 3 жыл бұрын
thank you so much for your feedback.. 😊
@nicolas-yates
@nicolas-yates Жыл бұрын
For those facing the issue with multiple parallel requests. This ensures the loader isn't set to false until all requests are completed: @Injectable() export class LoaderInterceptor implements HttpInterceptor { private count = 0; constructor(private loaderService: LoaderService) {} intercept(request: HttpRequest, next: HttpHandler): Observable { this.loaderService.isLoading.next(true); this.count++; return next.handle(request).pipe( finalize(() => { this.count--; if (this.count === 0) { this.loaderService.isLoading.next(false); } }) ); } }
@johnherrera5913
@johnherrera5913 3 жыл бұрын
Master!!! Very nice and crystal clear explanation, thank u for sharing your knowledge.
@shaheershukur
@shaheershukur 3 жыл бұрын
Glad it was helpful!😊
@AkshayGothwal
@AkshayGothwal 2 жыл бұрын
far far better then anyone easy to understand to the point
@TheOfficialMovmnt
@TheOfficialMovmnt 3 жыл бұрын
Thank you for sharing! I’m definitely subscribing to you after watching this video. You explained everything very well. Thank you and keep it up!
@shaheershukur
@shaheershukur 3 жыл бұрын
Awesome! Thank you!😊
@angelsevilla406
@angelsevilla406 3 жыл бұрын
Clear and easy to understand, thanks so much, I'll watch your content more often from now on.
@Prodigyfer
@Prodigyfer 3 жыл бұрын
Worked like a charm in 15min. Thank you!
@HibiTeamQueso
@HibiTeamQueso Жыл бұрын
Keep the videos coming, this is great and much better explained than others
@chemakhiimad6325
@chemakhiimad6325 2 жыл бұрын
thank you very much for this solution. except when tiny problem with it, when debuggin the app it shows this ExpressionChangedAfterItHasBeenCheckedError error
@orangeyt2262
@orangeyt2262 3 жыл бұрын
Gracias por compartir tus conocimientos, Thank you for sharing your knowledges
@hazemhasan4931
@hazemhasan4931 3 жыл бұрын
Hi, Thanks for this video, I just have a question : how can we do to call that the interceptor just when we load the data?
@sunits3300
@sunits3300 3 жыл бұрын
the interceptor will be called in any http call in and out of the app
@rafaelyahu
@rafaelyahu Жыл бұрын
its work but I get error Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'
@ahmeda.maksoud9637
@ahmeda.maksoud9637 2 жыл бұрын
Thanks , but It does not work with multiple parallel http requests
@uvindupathirana3221
@uvindupathirana3221 3 жыл бұрын
Thank you very much this was the thing I was searching for😁❤👌😊😍!!
@sofianezerrouki
@sofianezerrouki 2 жыл бұрын
Big information at small time, Thanks a lot
@Vicky16987
@Vicky16987 2 жыл бұрын
this is very useful for my application development sir
@thamizhmanims
@thamizhmanims 2 жыл бұрын
Great tutorial, Thanks for sharing. But I am getting : "NG0100: Expression has changed after it was checked" error in the console. How can I fix this?
@rafaelyahu
@rafaelyahu Жыл бұрын
me too
@abhijeetrkv
@abhijeetrkv 3 жыл бұрын
Nicely explained and works with Angular 11 as well, Subscribing the channel right away.
@thaisonvu4306
@thaisonvu4306 3 жыл бұрын
You make my day better. Thanks!
@bbogdanz
@bbogdanz 3 жыл бұрын
Very good tutorials! Cheers man!
@arturkhachatryan63
@arturkhachatryan63 2 жыл бұрын
Thank you, very perfectly tutorial and simple understand!
@danieleduardo1085
@danieleduardo1085 2 жыл бұрын
Thanks i need implement this characteristcs and it worked
@havefun5519
@havefun5519 Жыл бұрын
I loaded 10000+ data rows, however api time is finish in 2.79s with interceptor however dev tools network tab, the API preview data is not load actually, need to wait for around 10s+ and page freeze. Any idea?
@avk1943
@avk1943 2 жыл бұрын
this is great even explaining the small details
@joaocarlosgoncalves5405
@joaocarlosgoncalves5405 2 жыл бұрын
Thank you, clear and easy understand
@pigamerpt1835
@pigamerpt1835 3 жыл бұрын
Thank you so much! Perfect tutorial
@shaheershukur
@shaheershukur 3 жыл бұрын
Glad you liked it!😊
@tuananhngyen2985
@tuananhngyen2985 3 жыл бұрын
I don't think this is the exact behavior that KZbin implemented because I notice that KZbin shows the progress bar while fetching data for the next route and as soon as all data is fetched, the progress bar disappears then new view (component) along with its data shows up
@ijazkhan-mq4jy
@ijazkhan-mq4jy 2 жыл бұрын
Wow Sir you are genius thankssss
@rekhamali8498
@rekhamali8498 3 жыл бұрын
Thank you so much for logic for spinner
@prashanthnaidu11
@prashanthnaidu11 4 жыл бұрын
Thanku Sir ...For The video! 👌
@shaheershukur
@shaheershukur 4 жыл бұрын
Most welcome 😊.. glad you like it!
@alphaarani2576
@alphaarani2576 Жыл бұрын
Hii, How to set a value from 0 to 100 in the progress-bar when waiting for the request to finish?
@waldBestMusics
@waldBestMusics 3 жыл бұрын
Hi, Thx for the video, really helpfull, could you make more angular videos, !, really well explained.
@TrungNguyen-iz2zk
@TrungNguyen-iz2zk Жыл бұрын
it works perfect thank you so much
@themusikislive
@themusikislive 3 жыл бұрын
very very thank you, how easily explain
@randommosta2489
@randommosta2489 2 жыл бұрын
working...super thanks
@GuilhermeAlmeida-qh1fe
@GuilhermeAlmeida-qh1fe Жыл бұрын
Thanks for the help!
@dusabaneduardc.4516
@dusabaneduardc.4516 3 жыл бұрын
You are so great! Just Wow thaaanks
@abdullahbinabdullah3064
@abdullahbinabdullah3064 4 жыл бұрын
Sir which text to speech software you are using in your video ?
@shaheershukur
@shaheershukur 4 жыл бұрын
Hi abdulla, im using animaker voice web app for TTS
@abdullahbinabdullah3064
@abdullahbinabdullah3064 4 жыл бұрын
@@shaheershukur thanks bro ❤️
@TheWilsonlol
@TheWilsonlol 2 жыл бұрын
Great video! Thanks!
@ivansxturno
@ivansxturno 3 жыл бұрын
Thanks man, you're the best
@snehapidikiti8011
@snehapidikiti8011 2 жыл бұрын
How to implement loader for websocket url call through this interceptor concept?
@panyafuang4038
@panyafuang4038 3 жыл бұрын
Thank you It's very cool, Can you make dark them tutorial ?
@shaheershukur
@shaheershukur 3 жыл бұрын
I believe it's already present at 7:49 . However, you may also take a look at this kzbin.info/www/bejne/qGe8mKpvgZposMk
@MohamedFathyKamalAboelmaged
@MohamedFathyKamalAboelmaged 3 жыл бұрын
Best of the best
@dayachoudekar8
@dayachoudekar8 4 жыл бұрын
Very nice vidoe. I loved it
@shaheershukur
@shaheershukur 4 жыл бұрын
Thank you so much daya 😀
@juliano9052
@juliano9052 2 жыл бұрын
Thank you so much!
@goranqaqnass5867
@goranqaqnass5867 5 ай бұрын
that was great thanks
@ricardovalenciamartinez5072
@ricardovalenciamartinez5072 3 жыл бұрын
Excelent video!
@mmk1334
@mmk1334 3 жыл бұрын
very helpful thanks
@ams1ams53
@ams1ams53 3 жыл бұрын
It works but I am getting this Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError
@arleydavidvelasco5761
@arleydavidvelasco5761 3 жыл бұрын
i have the same error
@insomniety
@insomniety 2 жыл бұрын
I'm encountering the same error. Anyone solved it?
@Rubariton
@Rubariton 2 жыл бұрын
I encountered the same error. I figure that HTML doesnt really like observables in an *ngIF statement as it gets confused on what to do. Instead how i fixed it is to bind it to hidden. Example: x.component.html: Loading data ... interceptor.service.ts: export class InterceptorService implements HttpInterceptor { constructor(public loaderService: LoaderService) {} count = 0; intercept( req: HttpRequest, next: HttpHandler ): Observable { if (this.count === 0) { this.loaderService.isLoading.next(true); // To only submit the value of true to the isLoading observable once, instead of spamming it with true } this.count++; // Increments count by 1 for each http request return next.handle(req).pipe( finalize(() => { this.count--; // substract the count for each http req that has been fullfilled // if count is 0 then all reqs have been fullfilled and isLoading wont go to false to early if (this.count === 0) { this.loaderService.isLoading.next(false); } }) ); } }
@Поканепридумал-и3э
@Поканепридумал-и3э 2 жыл бұрын
@@insomniety use OnInit hook when initialize your observable variable
@viniciusalves5893
@viniciusalves5893 2 жыл бұрын
Great video!!!!
@vidyasagarkota9813
@vidyasagarkota9813 2 жыл бұрын
I'm getting ERROR in console: core.mjs:7635 ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.🤥
@alphaarani2576
@alphaarani2576 Жыл бұрын
You need add in your constructor "private cdref: ChangeDetectorRef" Then add: ngAfterContentChecked() { this.cdref.detectChanges(); }
@bluesynthsoftwarelabs2453
@bluesynthsoftwarelabs2453 2 жыл бұрын
Thank you
@Alfredfreezy3
@Alfredfreezy3 3 жыл бұрын
Beautiful
@shaheershukur
@shaheershukur 3 жыл бұрын
Thank you! Cheers! 😊
@frontenddevtech1155
@frontenddevtech1155 3 жыл бұрын
Super Video
@shaheershukur
@shaheershukur 3 жыл бұрын
Thanks 🙂
@SLCODEGEN
@SLCODEGEN 2 жыл бұрын
Thank you!
@loctong88
@loctong88 3 жыл бұрын
awesome, thank you
@pusarlaaishwarya5035
@pusarlaaishwarya5035 3 жыл бұрын
Ohhh sorry ...tqs anyway👍👍👍...nice video👍👍👍
@shaheershukur
@shaheershukur 3 жыл бұрын
Hi Aishwarya, here's the link github.com/shaheershukur/Market-Web-Application *btw it was already mentioned in the video description 😊
@jobinwilfred6391
@jobinwilfred6391 4 жыл бұрын
does it work when we have multiple api calls when a page loads
@shaheershukur
@shaheershukur 4 жыл бұрын
Yes.. that is the main reason we use interceptor, to tap each and every requests. In this example, Interceptor will update the BehaviorSubjects value(which in turn hides and unhides the loader) even for multiple api calls.
@jobinwilfred6391
@jobinwilfred6391 4 жыл бұрын
@@shaheershukur but if an api call finishes early, before another call in the same page, which will result in turning off the loader before the second call completes. right?
@shaheershukur
@shaheershukur 4 жыл бұрын
Ok, now I got you.. In case there are multiple service calls to be made in a single page itself, we may consider adding a counter variable in the interceptor service. Whenever service call(multiple) starts, increment it.. And inside the finalize() method, decrement the count.. at last, IF AND ONLY IF the counter has value 0, turn off the loader.... I believe that can solve the issue.
@jobinwilfred6391
@jobinwilfred6391 4 жыл бұрын
@@shaheershukur Thanks👍
@shaheershukur
@shaheershukur 4 жыл бұрын
@jobin thank you so much for this question.. it may help other too.. 👍😊
@tanmayingole8495
@tanmayingole8495 2 жыл бұрын
thank you :)
@shaleemabasheer7063
@shaleemabasheer7063 4 жыл бұрын
✌👌
@shaheershukur
@shaheershukur 4 жыл бұрын
Thanks 😊
@leoguillaume5682
@leoguillaume5682 3 жыл бұрын
thanks :)
@abrincsaiju9842
@abrincsaiju9842 4 жыл бұрын
malayali anno ....
@shaheershukur
@shaheershukur 4 жыл бұрын
haa athe..😄
@abrincsaiju9842
@abrincsaiju9842 4 жыл бұрын
Polii
@thanhphongquach1690
@thanhphongquach1690 3 жыл бұрын
Thank you so much!
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
火影忍者一家
Рет қаралды 112 МЛН
Synyptas 4 | Жігіттер сынып қалды| 3 Bolim
19:27
Error Handling in Angular - Complete Guide (2022)
41:27
Decoded Frontend
Рет қаралды 69 М.
ngTemplateOutlet is WAY more useful than I realised
16:36
Joshua Morony
Рет қаралды 75 М.
Adding a Spinner to Angular App on Outgoing HTTP Calls
5:50
Learn Smart Coding
Рет қаралды 1,8 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 638 М.
Loading indicator done right | Angular Tips and Tricks
17:51
Code With Gio
Рет қаралды 7 М.
WARNING Don't Make This HTTP Interceptor Mistake in Angular 18
6:28
Learn Smart Coding
Рет қаралды 1,6 М.
I built 10 web apps... with 10 different languages
14:23
Fireship
Рет қаралды 1,6 МЛН
Every React 19 Feature Explained in 8 Minutes
7:35
Code Bootcamp
Рет қаралды 131 М.
Difference Between REST API vs Web API vs SOAP API Explained
7:24
Learn with Whiteboard
Рет қаралды 219 М.
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
火影忍者一家
Рет қаралды 112 МЛН