Resolver Guard in Angular Router (2021)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 64

  • @DecodedFrontend
    @DecodedFrontend  3 ปีที่แล้ว +5

    Please use the time codes in the video description, leave your feedback, and check out my Angular Courses - courses.decodedfrontend.io
    UPDATE: In the video, I forgot to mention that when the error happens in the resolver observable, the NavigationCancel event is fired instead of ResolveEnd which might cause the loading animation to be stuck. It could be solved by extending the filter operator in _hideLoaderEvents$ by filter((e) => e instanceof ResolveEnd || e instanceof NavigationCancel).

  • @davicampos802
    @davicampos802 3 ปีที่แล้ว +9

    This channel is amazing , there is no word , every video you post about angular motivates me to learn

    • @DecodedFrontend
      @DecodedFrontend  3 ปีที่แล้ว

      Happy to hear that! and your motivation motivates me to make more videos ;)

    • @dragorwyin9809
      @dragorwyin9809 3 ปีที่แล้ว

      @@DecodedFrontend Yeah, that's true! Don't stop to upload such a great content. Even your sense of humor and faults are great :D Keeping those movies alive!

  • @Panossa
    @Panossa 11 หลายเดือนก่อน +2

    I feel like 13:26 could be done much easier, in one Observable instead of three. Something along the lines of:
    export class AppComponent implements OnInit {
    isLoading$!: Observable;
    constructor(private router: Router) {}
    ngOnInit(): void {
    this.isLoading$ = this.router.events.pipe(
    filter((e) => e instanceof ResolveStart || e instanceof ResolveEnd),
    map((e) => e instanceof ResolveStart)
    );
    }
    }
    When the event is a start event, it'll get mapped to true; else to false. No need to merge Observables or even have them on a class-level as variables. Or am I missing something?

  • @yuwenchiou3911
    @yuwenchiou3911 8 หลายเดือนก่อน

    best angular tutorial i've seen so far, very practical, clear and useful.

  • @SunnyVakil
    @SunnyVakil 3 ปีที่แล้ว +3

    Really I got some more insight every time when I’m watching your videos, Can you make something for global errors handling in Angular. Last but not least Thank you so much ! for amazing and informative videos.

  • @TheNsn666
    @TheNsn666 3 ปีที่แล้ว +3

    you should make unit test deep dive that would be awesome

  • @akshaymhatre9123
    @akshaymhatre9123 3 ปีที่แล้ว +4

    I get to learn new things with every video that you make. Great video as always.
    One suggestion - While uploading project on Github, can you create 2 branches, one with starter code and other with the Final solution?

    • @AlphaFrog1021
      @AlphaFrog1021 3 ปีที่แล้ว

      that's really good idea I hope he sees it

    • @DecodedFrontend
      @DecodedFrontend  2 ปีที่แล้ว +1

      I see it :) Thanks for suggestion, I will keep in mind it next time!

  • @janardhanangurusamy1658
    @janardhanangurusamy1658 3 ปีที่แล้ว +3

    Really amazing video to understand all the angular concepts more clearly 👏

  • @pedrofernandes2005
    @pedrofernandes2005 3 ปีที่แล้ว

    The routing resolve events is really useful, didn't know we have that.

  • @aleksandrm3466
    @aleksandrm3466 3 ปีที่แล้ว +1

    This is super as usual, thanks a lot. It would be cool to see some video from you regarding RxJS operators that you often use and best places to use. Thanks in advance:)

  • @craigiswayne
    @craigiswayne 3 ปีที่แล้ว +3

    Great content, loved the techniques you used, especially merging of the observable streams, super useful.
    What I would have liked to have seen is the error scenario handling, to see what happens

  • @isasunasra9910
    @isasunasra9910 2 ปีที่แล้ว

    Awesome, just what I was looking for months, TYSM

  • @gonzaloetchegaray5998
    @gonzaloetchegaray5998 3 ปีที่แล้ว

    Nice video! The content of this channel is amazing. This kind of content is hard to find.

  • @mrthefankyy
    @mrthefankyy 3 ปีที่แล้ว +1

    Guy, make all for being as a "Google Angular Developer Expert". Good luck!

    • @DecodedFrontend
      @DecodedFrontend  3 ปีที่แล้ว +2

      Hi Dmitry! Believe or not, but this morning I officially became a Google Developer Expert in Angular 😄

  • @carlosiglesias8354
    @carlosiglesias8354 3 ปีที่แล้ว

    thanks again! I just copied your code into my project!😀

  • @krisnarusdiono1304
    @krisnarusdiono1304 3 ปีที่แล้ว +2

    yeay, a course that i was looking for

  • @sakarsr
    @sakarsr 3 ปีที่แล้ว +2

    Thank you for this video, please let me know what extension your using to generate the resolver in vs code?

    • @DecodedFrontend
      @DecodedFrontend  3 ปีที่แล้ว +1

      Hi! Thanks for a feedback. It called NX Console

    • @sakarsr
      @sakarsr 3 ปีที่แล้ว

      @@DecodedFrontend thank you

  • @santhoshreddy7555
    @santhoshreddy7555 2 ปีที่แล้ว

    Great video thank you. Can we use mutliple 's and can we display two angular applications in single page? pls tell me

  • @sweetsamikshya
    @sweetsamikshya 3 ปีที่แล้ว

    I am learning so much from you man :)

  • @nanasarathi
    @nanasarathi 2 ปีที่แล้ว

    Very informative 👍

  • @santoshraju9230
    @santoshraju9230 3 ปีที่แล้ว

    Excellent!! Nice explanation. Thanks

  • @hadirahmani7943
    @hadirahmani7943 2 ปีที่แล้ว

    Thank you very much 😎😎😎

  • @amar-iby
    @amar-iby 3 ปีที่แล้ว

    thank you for this amazing video !

  • @VladyslavHaidar
    @VladyslavHaidar 2 ปีที่แล้ว

    Great video! What if we navigate to specific route second time, but don't want to see this 'progress-bar event' again. Can we cache our data with this Resolver and is it make sense?

  • @biniyammoges9040
    @biniyammoges9040 3 ปีที่แล้ว

    it helped me! thanks bro

  • @mktrann
    @mktrann ปีที่แล้ว

    Thank you so much ❤!

  • @wiliam334
    @wiliam334 ปีที่แล้ว

    Thank you for it.
    But can u show us how to resolve the user data on page refresh once the user is on the user details page.
    In the example above the users url was harcoded on the user service. But how would u solve if the url was on the parent component?
    Thank you😊

  • @kelvinticllahuanacohuachac9562
    @kelvinticllahuanacohuachac9562 3 ปีที่แล้ว

    Amazing bro, nice explanation. thanks a lot.

  • @TimmyPl
    @TimmyPl 2 ปีที่แล้ว

    Hi, what if the case if I want refresh resolved data ? I mean, in „shared service” way I will create something like refreshData subject and switchMap with it. How can I achieve this kind of behaviour in resolver ? Should I refresh entire page to get routing kick in and refresh the data ?

  • @andresmauriciofajardoolaya2721
    @andresmauriciofajardoolaya2721 3 ปีที่แล้ว

    excellent video, thanks for spend your time do it

  • @bigk9000
    @bigk9000 2 ปีที่แล้ว

    I have that same extension that displays the import cost; however, whenever I import anything from `rxjs` (and not `rxjs/internal/Observable` or the like), mine reads out as "144.1k (gzipped: 28.6k)" while yours reads as "8.8k (gzipped: 2.8k)".
    Is there a certain setting I need to configure with the extension? Or is there something you have established with your app's configurations/settings?
    Like I alluded to previously with `rxjs/internal/Observable`, I saw this video on boosting an Angular app's performance (that was narrated and assumingly written by Jeff Delaney/Fireship), and he recommended to start importing from `rxjs/internal/Observable` directly. I also know there are the "static imports" that work like `import 'rxjs/Observable/add/map` or the like. I'm never sure which one I should use for which particular use case. Is there a diagram, a chart, or a question diagram/tree I can use for a reference?
    Apologies for the word vomit, but this has been an issue I've been trying to wrap my head around for a while and noticing the remarkably small import size you were getting for RxJS modules was incredibly perplexing for me.
    Any assistance is much appreciated!

  • @craigiswayne
    @craigiswayne 3 ปีที่แล้ว

    love your hair! content is great as well, thanks

  • @rs4267
    @rs4267 9 หลายเดือนก่อน

    An other banger thanks 🎉

  • @carlosiglesias8354
    @carlosiglesias8354 3 ปีที่แล้ว +1

    Great resource

  • @b4m5
    @b4m5 3 ปีที่แล้ว +1

    Thanks a lot, bro 🤟

  • @dennis87ist
    @dennis87ist 2 ปีที่แล้ว +1

    It's admitted to inject some Store into the resolvers and dispatch action from them? Or the best practice is to inject the store only in parent component and dispatch all the actions needed to load it and all it's children?

    • @DecodedFrontend
      @DecodedFrontend  2 ปีที่แล้ว

      I personally do not see any problems with that. Of course, it depends a lot on a concrete use-case but if you need, for instance, to dispatch some action or resolve data which depends on data from the Store and you need to do it right before the component for the route will be activated, then I do not see any other option as to inject the store in your resolver and use it there.

  • @minnininja4777
    @minnininja4777 2 ปีที่แล้ว

    Its great video, thanks for it. Also can you please tell me the extension you are using to show the imported module size in kb ?.
    Thanks in Advance.

    • @DecodedFrontend
      @DecodedFrontend  2 ปีที่แล้ว +1

      Hi! It is this vs code extension marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost

    • @minnininja4777
      @minnininja4777 2 ปีที่แล้ว

      @@DecodedFrontend thanks bro

  • @wiliamferraciolli5380
    @wiliamferraciolli5380 2 ปีที่แล้ว

    Hi thanks for the tutorial, but can you make one where the resolver depends on another resolver?
    Eg in this very same scenario where the user deep link onto a single user.
    But the difference would be that instead of hard coding the Users link, this would be provided by another resolver
    So getUsers need a resolver to get the list of users and its link (profile) then getUser will need to get the link from the usersResolver to them append the id to it
    thanks

  • @khumozin
    @khumozin 3 ปีที่แล้ว +1

    Nice video, however this does not work on Angular 12, please assist.
    Thanks

    • @khumozin
      @khumozin 3 ปีที่แล้ว

      Actually, I'm using a resolver with a guard

    • @DecodedFrontend
      @DecodedFrontend  3 ปีที่แล้ว

      Hi Khumo,
      Thanks for your feedback. Actually, it works with Angular 12.x, you probably should look for the issue on your end.

  • @ShashankGram
    @ShashankGram 3 ปีที่แล้ว

    Thank you

  • @ariyoayodejiifeoluwa65
    @ariyoayodejiifeoluwa65 ปีที่แล้ว

    please what's the name of the extension you used to generate the resolver

  • @covertgravy
    @covertgravy 3 ปีที่แล้ว

    will something like this resolve?
    return {
    listA: Observable,
    listB: Observable
    ...
    }

  • @dmrshack
    @dmrshack 2 ปีที่แล้ว +2

    you are the good teacher, but sometimes we didn't understand because you start video and you are already create project and configure everything, that lost us...