Angular Design Patterns - Bridge [Advanced, 2020]

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 27. 07. 2024
  • đŸ’„ Learn how to build custom form controls like select dropdown with multiselection in my new advanced Angular Forms course bit.ly/advanced-angular-forms đŸ’„
    ✂Use coupon CZcams_DISCOUNT to get a 10%-off discount✂
    In today’s advanced tutorial we will start with Angular design patterns and in particular - the "Bridge" pattern. This pattern might be very useful in some particular cases especially when you have some group of components that might have the same API but very different implementations. Besides this, we will touch such intersecting topics like content projection, ContentChild decorator, and the use of InjectionToken and DI. It will allow us to build a nice abstraction layer that allows us to interact with child components without knowing exactly about their type and to resolve them dynamically. Share this video with your colleagues if you find this video useful. Thank you for your attention and enjoy watching :)
    🕒 Time codes:
    00:00:00 - Intro;
    00:00:35 - My annoying talking ends here ;)
    More videos about Angular Material Library:
    ‱ Angular Material
    More videos about Angular Material CDK:
    ‱ Angular Material CDK
    🔗 Links:
    Link to Github repo:
    github.com/DMezhenskyi/angula...
    #webdevelopment #angularmaterial #typescript
  • Věda a technologie

Komentáƙe • 185

  • @vijayjx
    @vijayjx Pƙed 3 lety +39

    After a long time, I have seen a serious angular CZcamsr with advanced content. Videos are very good and explained very well.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Glad to hear that! Thank you :)

    • @shivanigaddagimath6105
      @shivanigaddagimath6105 Pƙed 3 lety

      Hi Vijay! Would you be interested in exploring job opportunities in web development currently? We are a web dev company and looking for developers. Let me know if interested!

  • @emjaytripleo
    @emjaytripleo Pƙed 3 lety +9

    I'm on a spree watching your videos, a breath of fresh air

  • @muhammadrehan2243
    @muhammadrehan2243 Pƙed rokem +2

    After a long time, I have seen an advanced angular CZcamsr with advanced content. I just loved how you explain things, and really is putting some advanced Angular concepts into practice, please never stops and keep bringing us this awesome advanced content

  • @kornelsiket3420
    @kornelsiket3420 Pƙed 3 lety +2

    This the kind of Angular content I want to see on youtube. Nice solution.

  • @dubeykivines9202
    @dubeykivines9202 Pƙed 3 lety +24

    Ooh I was not aware of this kind of implementation earlier, Great job dude. It is actually an Advance talk.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Hi! Thanks for feedback ;) Yes, it is advanced. Enjoy!

    • @shivanigaddagimath6105
      @shivanigaddagimath6105 Pƙed 3 lety +1

      Hi ! Would you be interested in exploring job opportunities in web development currently? We are a web dev company and looking for developers. Let me know if interested!

  • @gund_ua
    @gund_ua Pƙed 4 lety +26

    Awesome tutorial with clear explanation as usual, thanks!
    I would suggest you to also maybe briefly discuss the Bridge Design Pattern alone before jumping on implementation with Angular so we can have a clearer idea of what exactly we want to achieve using Angular's DI (some diagrams probably would help).
    But thanks again this was a great explanation! =)

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 4 lety +4

      Hi Alex!
      This is a great and meaningful feedback. Thank you very much!
      I will definitely take it into account your suggestion in next video 😉

  • @GuillermoArellano
    @GuillermoArellano Pƙed 3 lety +11

    Phenomenal coverage of an advanced topic. Not even GDEs are this good at explaining Angular like you. Keep up the excellent work!

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      Thanks a lot! :) I appreciate it and glad you liked it!

  • @olaosman7520
    @olaosman7520 Pƙed 2 lety +3

    soooo useful to me .I really need to advanced level concepts so i can level my understand up of Angular .. Thank you

  • @sajidkhan127
    @sajidkhan127 Pƙed 2 lety +2

    Just bought one of your courses after watching this video👍

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 2 lety +1

      Thank you for your support! I hope you will like it!

  • @VinodShyave
    @VinodShyave Pƙed 2 měsĂ­ci +1

    Learnt new things, thanks for explaining amazing concepts

  • @MoMoadeli
    @MoMoadeli Pƙed 3 lety +2

    Awesome as always. Note, NgTemplateOutlet could be an alternative approach making the concrete components similarly irrelevant to the wrapper component. That way a new interface or injection token wouldn't be needed as well. Many thanks for your great tutorials.

  • @doncooper6354
    @doncooper6354 Pƙed rokem

    This is a very slick and elegant pattern, thank you! My one critique on your videos: Please pre-build all the functionality and go directly to the heart of the advanced concepts you want to explain. Also, if the title of your video is referring to the bridge pattern, explain it briefly and then relate it to the material. I caught the one sentence you uttered where you say it is the token that makes it a bridge. It made sense but it was very small detail in your explanation. Highlight the important points and get to them quickly. Your videos are really good, but if you want them to be truly useful you should not assume we have infinite time to watch you type code and explain the obvious things in the code we can see. In short: be brief and succinct. This could have been a three-to-five minute video, which is much, much more useful than half an hour. In any case, I really appreciate your help. Thanks again!

  • @sudeshkodavoor548
    @sudeshkodavoor548 Pƙed 3 lety +3

    Very Nice video.. Got to know so many concepts.. Thanks for last minute explanation on how it works.. I understood lot of things.. Thank you

  • @wolfisraging
    @wolfisraging Pƙed 3 lety +7

    Excellent job buddy, youtube really needs such high quality and descriptive angular videos. Thanks a ton.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Thank you for feedback! I am happy to hear that you like it :)

  • @ilirbeqiri253
    @ilirbeqiri253 Pƙed 2 lety +1

    Absolutely amazing. Thanks for this explanation 🚀

  • @felixenghofer4616
    @felixenghofer4616 Pƙed 2 lety +1

    Very useful stuff, thanks! Very well explained.

  • @FFizmaTT
    @FFizmaTT Pƙed 3 lety +1

    Good job, Dmytro! Very actual problem and very good solution!

  • @agharajubin7027
    @agharajubin7027 Pƙed 2 lety +1

    Wow...Super awesome technique. Thanks for sharing. 🎉

  • @rhea8133
    @rhea8133 Pƙed 2 lety +2

    thankyou for your videos. i always look forward to your videos !

  • @nikitasologub3549
    @nikitasologub3549 Pƙed 3 lety +4

    Great job! Awesome explanation and really good examples

  • @ash1982ok
    @ash1982ok Pƙed 2 lety +1

    I can't thank you enough for explaining so nicely. Amazing topics and the way you explain is awesome. Keep posting good videos like this. I wish you get whatever you want in life...

  • @RomaNovomodnyi
    @RomaNovomodnyi Pƙed 8 měsĂ­ci

    Thanks! It was a perfect explanation, good job Dmytro đŸ’Ș👍!!!

  • @tarassavchenko2317
    @tarassavchenko2317 Pƙed 3 lety +1

    This is just brilliant, I'm so happy I found your channel

  • @Perun42
    @Perun42 Pƙed rokem +1

    Thank you a lot, Dmitro. ĐĐ±ĐŸ ĐżŃ€ĐŸŃŃ‚ĐŸ Ń‰ĐžŃ€ĐŸ ЮяĐșую :)

  • @fkyates9099
    @fkyates9099 Pƙed 7 měsĂ­ci

    Clear examples well explained. Thanks!

  • @MatiasAlibertti
    @MatiasAlibertti Pƙed 3 lety +2

    Amazing content man, keep going!

  • @demidovmaxim1008
    @demidovmaxim1008 Pƙed 3 lety +1

    Thank you for this video and your channel!

  • @bernardvlado8826
    @bernardvlado8826 Pƙed 2 lety +2

    This is really useful video. I was looking for something like this for a long time. Thank you that you are creating this kind of advanced Angular topics.

  • @ariMuayad
    @ariMuayad Pƙed 3 lety +1

    Thank you so much, I appreciate your efforts.

  • @gleisonsubzeroKZ
    @gleisonsubzeroKZ Pƙed 3 lety +7

    Where have you been, bro? I just loved how do you explain things, and really is putting some advanced Angular concepts in practice, please never stops and keep bring us this awesome advanced content.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Thank you for such a great feedback! I am glad you like it ;)

  • @user-xk8tk4et4g
    @user-xk8tk4et4g Pƙed 3 lety +2

    thank you it is really helpful !!! keep going

  • @cinnamonrage
    @cinnamonrage Pƙed rokem

    Quite late to finding your videos but they are super useful - thank you!

  • @IngvarLosev
    @IngvarLosev Pƙed rokem

    Great lesson! Thank you.

  • @afsarzan
    @afsarzan Pƙed 3 lety +2

    Thank you for explanation. Good example.

  • @dfytq
    @dfytq Pƙed rokem

    simply a mind-blowing explanation boss.

  • @sourishdutta9600
    @sourishdutta9600 Pƙed 3 lety +3

    It's really awesome , thank you so much. Can you please discuss deeper on this injection token, injector and how angular resolve the dependency through token. Keep marking videos like this. Excellent work.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      Noted! Thanks for suggestion

    • @sourishdutta9600
      @sourishdutta9600 Pƙed 3 lety

      @@DecodedFrontend I have watched your session on Angular air. Really awesome. I want to thank you for sharing this good amount knowledge 🙏 keep teaching us more.

    • @shivanigaddagimath6105
      @shivanigaddagimath6105 Pƙed 3 lety

      Hi Sourish! Would you be interested in exploring job opportunities in web development currently? We are a web dev company and looking for developers. Let me know if interested!

  • @violetaveleva6143
    @violetaveleva6143 Pƙed 2 lety +1

    Thanks for the great content!

  • @fatihersoy7559
    @fatihersoy7559 Pƙed 2 lety

    This is a great example of bridge pattern illustration. Most cases I see on the internet as "bridge pattern" example, they are just equivalent to Strategy pattern, so there are no reasons not to use strategy pattern, but this example clearly is suitable for Bridge. Good job!

  • @zeeshanazmat719
    @zeeshanazmat719 Pƙed 3 lety +3

    Good job man!!! Loved it

  • @_cipriangg_
    @_cipriangg_ Pƙed 2 lety +1

    Awesome content!

  • @SaurabhGangamwar
    @SaurabhGangamwar Pƙed 3 lety +2

    Thanks man.
    I used to do lot of if elss statment to identify the context.
    Definitely will give it a try.👍

  • @floinseler
    @floinseler Pƙed 3 lety +1

    Great Content, very useful

  • @robrabbit8288
    @robrabbit8288 Pƙed 4 lety +4

    Nice and clear!

  • @AiguretDuren
    @AiguretDuren Pƙed rokem

    Excellent video. I finally understand something about tokens, and I learned something new about ContentChild (the `static: true` part)

  • @innocentmazando3808
    @innocentmazando3808 Pƙed 2 lety +1

    This is genius, thanks mate!

  • @mariamtsotsolashvili9079
    @mariamtsotsolashvili9079 Pƙed 2 lety +1

    It was helpful, Thanks

  • @artemshapilov668
    @artemshapilov668 Pƙed 3 lety +2

    thanks man, interesting stuff, goes good with the cup of tea :)

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      ŃĐżĐ°ŃĐžĐ±ĐŸ! Đ Đ°ĐŽ, Ń‡Ń‚ĐŸ ĐČĐžĐŽĐŸŃ зашДл)

  • @drone-plus-plus
    @drone-plus-plus Pƙed 3 lety +2

    Thank you! This is a good idea. I am doing something similar now and will try to do it in my task.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Great that you found usecase for it in your app 😉 thanks for feedback!

  • @waleedjubeh5955
    @waleedjubeh5955 Pƙed 2 lety +2

    Amazing content. Keep going

  • @Endless_Box
    @Endless_Box Pƙed 3 lety +1

    Thank you a lot i appreciate it !

  • @michastuleblak4998
    @michastuleblak4998 Pƙed 3 měsĂ­ci +1

    Great video! Thank You Dmytro ;)

  • @1Brockhenrie
    @1Brockhenrie Pƙed 2 lety

    ive been trying to figure out how you can select the widget from a dropdown or some sort of list to load them in dynamically. these videos are great. ive watched probably all your vids and love the dependency injection series, that really helped with this.

  • @a7md940
    @a7md940 Pƙed 3 lety +2

    Great trick!

  • @johnnyrockembachkraemer1566
    @johnnyrockembachkraemer1566 Pƙed 2 lety +1

    Thanks a lot bro!

  • @KamelJabber1
    @KamelJabber1 Pƙed 3 lety +11

    Fantastic video! There is a serious lack of advanced, "enterprise", angular guides. Looking forward to watching your remaining videos in the series and even more advanced topics!
    Consider zooming in vscode to make the code easier to read. GG

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +2

      Thank you very much for your feedback and great hint! It was already zoomed (175% both VS Code and the Browser) but may I ask you which device did you use for watching? So I would test it on something similar and try to adjust it.

    • @KamelJabber1
      @KamelJabber1 Pƙed 3 lety +1

      @@DecodedFrontend I was watching on a one plus 7 pro. To be a little more clear. I could read it, I just think a bit more would make it easier.
      Thanks so much for your reply and care! I appreciate your concern for striving to improve the quality of your video and care for your viewers!

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +2

      I see... I have checked today on a device with a similar screen and yeah.. it could be better.
      The problem is that when to zoom it up to (+200) then viewer sees less code strings and sometimes you're loosing context but I think I could decrease the size of the terminal because in 90% it is useless information there (just some compilation status). I will try it in the next video 😉

  • @teeassh7508
    @teeassh7508 Pƙed 3 lety +3

    Awesome, thanks!

  • @greg6618
    @greg6618 Pƙed 3 lety +2

    Big thanks to you, sir, for this helpful video. I've switched from react to angular and a lot of angular concepts is pretty new to me (as I am just a junior), and I struggle with all this OOP stuff, but with your explanations I can clarify this, and get better in creating reusable components and writing good extendable code. My admiration)

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      Hi Greg! It is awesome! I am glad that you make big progress and my video helps you with it 😉

  • @mustafadagloglu2071
    @mustafadagloglu2071 Pƙed 3 lety +2

    Awesome content, thanks! U have a subscriber from Turkey now :P

  • @miguelcastillo7346
    @miguelcastillo7346 Pƙed 2 lety

    Cool, thank you very much.

  • @nanasarathi
    @nanasarathi Pƙed rokem

    Hey Friend, it was really new learning for me... Thanks 🙏

  • @VendettaUkraina
    @VendettaUkraina Pƙed 3 lety +3

    Nice. I have some trouble to understand DI in the Angular, so after this video i founded some case where i can use this mechanism

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Thanks for a great feedback! I am happy that my video helped you. By the way my next upcoming video is exactly about DI in Angular 😉 it will be released on Monday

  • @user-ki3no7in5k
    @user-ki3no7in5k Pƙed rokem

    that's so cool. thanks

  • @GautamKumar-uideveloper
    @GautamKumar-uideveloper Pƙed 2 lety +2

    đŸ”„đŸ”„đŸ”„ Awesome topic.... waaaaaooo, It would be very helpful, if you start video playlist for Spartacus. ..:) You are a nice tutor .

  • @Id-me7gd
    @Id-me7gd Pƙed 3 lety +2

    Great explanation bro.

  • @raptorthefirst
    @raptorthefirst Pƙed rokem

    Nice explanation of injection tokens)

  • @josephsackeykontor4138
    @josephsackeykontor4138 Pƙed 3 lety +3

    Where have you been, bro? This is my first time watching your video and I really love it. I have already subscribed though.

  • @DecodedFrontend
    @DecodedFrontend  Pƙed 3 lety +4

    There is also another really cool use-case for actually the same pattern (but named differently). There we will dive a bit deeper czcams.com/video/iBA2VLvqNr4/video.html

  • @idlevandal69
    @idlevandal69 Pƙed 3 lety +2

    Exceptional... đŸ„‡

  • @gulsharangoraya6707
    @gulsharangoraya6707 Pƙed 3 lety +4

    I had no idea about this pattern until I watched your video. After watching it, I used this pattern to implement a reasonably complex validation in a text field. And it turned out to be one of the most elegant and robust solutions I have ever coded in Angular. Thanks a lot 🙏for making videos on such advanced Angular topics, I look forward to more such videos in future! Btw, any plans on making similar content for @NestJS? 😃

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Thanks for your feedback :) No NestJS isn't planned but .. let's see ;)

    • @shivanigaddagimath6105
      @shivanigaddagimath6105 Pƙed 3 lety

      HI Gulsharan! Would you be interested in exploring job opportunities in web development currently? We are a web dev company and looking for developers. Let me know if interested!

  • @beodan9219
    @beodan9219 Pƙed rokem

    very useful video

  • @kateellen445
    @kateellen445 Pƙed 3 lety +2

    great !!!

  • @carlosiglesias8354
    @carlosiglesias8354 Pƙed 3 lety +2

    Great!!!

  • @riazafridi519
    @riazafridi519 Pƙed rokem

    Love your content,
    Can you please make a video about “Strategy Patter” in Angular ?
    We would love to see it

  • @VolodymyrZub
    @VolodymyrZub Pƙed rokem

    nice example

  • @yuriinadilnyi3029
    @yuriinadilnyi3029 Pƙed 2 lety +1

    It was soooo useful

  • @Marcarrian
    @Marcarrian Pƙed 3 lety +3

    very underrated channel! you deserve way more views. I feel like there aren't many channels that explain advanced Angular concepts and you do an amazing job at it

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Thank you very much for such a great feedback! I am so happy to see that my videos bring some value for you :)

  • @wilbert2900
    @wilbert2900 Pƙed 3 lety +1

    Great video sir, you should be in Udemy!

  • @TheKyeZ
    @TheKyeZ Pƙed 3 lety +2

    Such a great job! Could you please then explain the difference between Bridge and Strategy design patterns?

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      Oh.. that's a good & hard question :)
      Well, very often implementation of Bridge and Strategy (also some other patters) is the same. Usually the difference just in intention. Bridge is about splitting abstraction and implementation on 2 different hierarchies which can be split independently. As example we have clear hierarchy for widgets (implementation) and it could be similar hierarchy for widget wrapper (abstraction), so both hierarchies could be developed and scale independently but stay compatible. It allows you to use any widget inside any wrapper and they will work. And Strategy pattern is about picking some concrete algorithm for some specific context. But yeah.. in this particular case when we have only one element in abstraction hierarchy is looks like Strategy pattern as well :)

  • @AlexAegisOfficial
    @AlexAegisOfficial Pƙed 3 lety +2

    Instead of wrapping calls in an if, you can just use optional chaining: this.weatherWidget?.refresh()

  • @arthurfedotiew3609
    @arthurfedotiew3609 Pƙed 3 lety +5

    A lot of thanks for such a valuable content. As always you've done a great job which all of us appreciate! though I am wondering about couple of things...
    Could we use abstract class instead of injection token? I suppose it would be possible both implementing it and providing it as a token. And, as well as that, are there any difference for our finale purpose, pehaps some edge cases which I am not aware about?

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +4

      Hi Arthur! Thanks for feedback!
      Yes, you can use abstract class as well. Injection Token has one small advantage though - it is a liiiitle bit more lightweight. Since ivy, angular creates during compilation a factory for abstract class as well but doesn’t do it for injection token. You can read more about it in this PR: czcams.com/users/redirect?event=comments&redir_token=QUFFLUhqa1RybHJrYmE3dzZFcC1EbFVXZ0J4LTh2bFdMd3xBQ3Jtc0tueEdkMnRrTU5SeXdwZkc1R1ZsVjdvbVhaTTFEem5XUlVGVlAyNEtxQllSR2FXYlMwY3lDN0MxTm5GUm1qb1RQeFUxVzVIZXNIdkVlSEdRNjU1ZVFmVDJHd1ItTkxxWjFjT2JYdFlxYWdoZEdXMFNFcw&q=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fpull%2F37506&html_redirect=1

  • @DecodedFrontend
    @DecodedFrontend  Pƙed 2 lety +2

    đŸ”„đŸ”„đŸ”„I just released one of the most advanced courses about Angular Forms. Check it out: bit.ly/advanced-angular-forms 👉Use coupon code CZcams_DISCOUNT to get a 15%-off discount

  • @josephsackeykontor4138
    @josephsackeykontor4138 Pƙed 3 lety +2

    Hello bro, I am really learning new things from your videos. By the way, could you please do a video on how to properly structure an angular app.

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Hi! Thank you for your feedback and this great suggestion! I will add it to my list of topics :)

  • @GaurangDhorda
    @GaurangDhorda Pƙed 3 lety +2

    Can you show more use-case where this bridge design pattern will be useful in angular ?

    • @shivanigaddagimath6105
      @shivanigaddagimath6105 Pƙed 3 lety

      HI Gaurang! Would you be interested in exploring job opportunities in web development currently? We are a web dev company and looking for developers. Let me know if interested!

  • @edisonfernandeza.462
    @edisonfernandeza.462 Pƙed 2 lety

    Hi!!! Is the best practice use setTimeout() or exist any recommendations? Thank you.

  • @kris3116
    @kris3116 Pƙed 3 lety +2

    What is the purpose of using injection token and how the load and refresh method were trigger? can u elaborate it? Thanks

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Hi! Sure.
      You can use also abstract class instead of injection token but in some cases InjectionTokens can have less impact on your bundle size. Check my last video czcams.com/video/iBA2VLvqNr4/video.html there you can also find comparison of both approaches and another use-case for this pattern.
      load and refresh methods will be called by parent component (WidgetWrapperComponent) when it heeds. As example refresh() is being called when user clicks on "refresh" button in WidgetWrapperComponent template and load when WidgetWrapperComponent initialised.

  • @Drujik
    @Drujik Pƙed 3 lety +3

    great implementation.
    question: what if I have several "widget" components inside wrapper. Is there a way to get a list of widgets and not only one?

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +5

      Hi Alex! Yes you can. Just use @ContentChildren annotation instead @ContentChild. @ContentChildren will return you QueryList, literally it is a list of Widget instances. The Data structure QueryList implements Iterable interface, so you can iterate through it as if it would be a usual array. Just remember that if you use @ContentChildren the "earliest" point when Widgets will be resolved is ngAfterContentInit hook. In ngOnInit it will be "undefined" 🙂

  • @SaurabhGangamwar
    @SaurabhGangamwar Pƙed 3 lety +1

    Is it possible to access the methods of the Host Component in the child component ?

  • @angelmunoz6332
    @angelmunoz6332 Pƙed 3 lety +2

    nice technique! is there a way to declare the provider in the NgModule instead of the components themselves? (in case each child component belongs to a specific module)

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      No, it will not work like you suggest. The whole idea here is that you configure (provide) services to a NodeInjector which is part of Component but when you configure it in NgModule you configure ModuleInjector. I have a video series about Angular Dependency Injection and would recommend you to have a look at it to understand why your suggestion won't work :) czcams.com/play/PLX7eV3JL9sfmJ6AaZj9eDlAKrJrEul4Vz.html

  • @arthurfedotiew3609
    @arthurfedotiew3609 Pƙed 2 lety +1

    Hey, Dmytro, after 8 months I came back to your video, which is a sign of LEGENDARY content) I've got another question now.
    This pattern you showed and called Bridge pattern reminds me of Strategy so hard, by both implementation and the problem you solved.
    Problem: you have a family of algorithms (widgets in our case) which has interface: Widget. These algorithms can do different things (concrete loading and refreshing implementations) and are being provided to the Context (WidgetWrapperComponent - concrete implementation, not abstraction) dynamically by use of DI which is great=) So that looks like a pure Strategy problem and pure strategy pattern implementation.
    The Bridge Pattern would be applicable if apart from Widget Abstraction we would have also wrapper abstraction.
    E.g. abstract class WidgetWrapper{
    abstract ngonInit(): void {}
    abstract onRefresh(): void{}
    }
    Then you could have a few concrete implementations of it: WidgetWrapperComponent1, WidgetWrapperComponent2...
    WidgetWrapperComponent - lets same it is the same as you showed in you example.
    LoggingWidgetWrapperComponent:
    LoggingWidgetWrapperComponent implements WidgetWrapper, OnInit {
    ngOnInit(){
    this.widget.load();
    console.log('Widget data is loaded')
    }
    onRefresh(){
    this.widget.refresh();
    console.log('Widget data is refreshed')
    }
    }
    But the main idea is not to find a way how to implement pattern, but to find a pattern that solves a general problem, and identify what general problem we have. And I think you solved it BRILIANTLY, but with Strategy instead of Bridge, which is a right way in this case most probably. Because once again I cannot see crucial part of Bridge: two hierarchies of abstractions. I see one abstraction - Widget, it's implementations - WeatherWidget, VelocityWidget, and a concrete context - WidgetWrapperComponent that uses Widget abstraction.
    What you think about it?

    • @denisbielishev
      @denisbielishev Pƙed rokem +2

      Hey man. I totaly agree with you. It looks like a Strategy pattern. It's a particular case of Bridge pattern. E.g. We have two different classes and each class has subclasses. We want to have like a bridge between parent classes. In this case we use Bridge pattern. But if we have only one hierarchy we can use Strategy patter.

  • @DzikiMoronHackshield
    @DzikiMoronHackshield Pƙed rokem

    It is interestng that firstly wrapper try to find provider in child, not in itself. It is not obvious to me, but I guess that ContentChild decorator causes that the starting point of searching is child, not place where decorator was implemented.

  • @gno3939
    @gno3939 Pƙed 3 lety +2

    great tuutorial- how would this work if you are using the same wrapper that contains more than 1 content children that extends the same interface. I guess you can use content-children and do some type of condition if > 1 then forEach.load / forEach.refresh.. seems kind of ugly though

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety

      Hi! Actually yes, you should use @ViewChildren and then call load method in forEach loop, but you do not need if> 1 check. It is fine actually to call method in the loop. As example if you have a look at design pattern Observer (do not confuse with RxJs Observables) you will see how observer’s method is being called in the loop :)

  • @user-yy6dv7bc4b
    @user-yy6dv7bc4b Pƙed 4 měsĂ­ci

    How can we apply the bridge pattern on view child ? Here we are using content projection but what if we call multiple components that needs to have different load behavior ?

  • @amirmahdi1507
    @amirmahdi1507 Pƙed rokem

    how can we use "useExisting: WeatherWidgetComponent" ? in fact I don't know when WeatherWidgetComponent key register in _container(map) (i believe value of useExisting should be exist in _container as key in relevant Injector class. is it wrong?

  • @denisBriceag
    @denisBriceag Pƙed rokem +1

    Hi Dmytro! Great tutorials, I really appreciate what you're doing!
    I think I missed something while exploring DI topic.
    Can we use two existing instances of two different classes for a single token key "WIDGET" without putting multi property to "true"

  • @Nabulio85
    @Nabulio85 Pƙed rokem +1

    You are angular black belt 😊

    • @DecodedFrontend
      @DecodedFrontend  Pƙed rokem

      At least somewhere I have reached it 😁

    • @Nabulio85
      @Nabulio85 Pƙed rokem

      @@DecodedFrontend 😂
      seriously, thank you for all these videos. it helps a lot others to progress. I will take your course on graphql soon. is there another way to support your work? paypal or other platform?

    • @DecodedFrontend
      @DecodedFrontend  Pƙed rokem +1

      @@Nabulio85 Glad to hear that my videos help, Kevin! Yeah, I have a link on PayPal for those who would like to support the channel - bit.ly/donate-to-decoded-frontend
      Much appreciate it :)

  • @WorthyVII
    @WorthyVII Pƙed 3 lety +1

    Why do you have to bother with the token stuff? Can't you just use the Interface inside the ContentChild input?

  • @franya173
    @franya173 Pƙed rokem +1

    Hi Dmytro, awesome video, I've been using this pattern since you uploaded this into your channel 😀
    Can you upload another version of this using Angular 15? haha. I'm kind of stuck right now on ng14 because this pattern no longer works with ng 15 😅

    • @DecodedFrontend
      @DecodedFrontend  Pƙed rokem +1

      Actually, this pattern works with Angular 15 :) I think your issue relates to something else.

    • @franya173
      @franya173 Pƙed rokem

      @@DecodedFrontend Lol. yea it was an error on my code during my migration to v15 from 14, I managed to fixed it haha, btw thanks for your response !!

  • @sudeshkodavoor548
    @sudeshkodavoor548 Pƙed 3 lety +2

    I have one question on this.. U shown how u can call a function from a parent to child using token.. In the same manner can i call a function from child to parent(I don't want to use event emitter)

    • @DecodedFrontend
      @DecodedFrontend  Pƙed 3 lety +1

      Hi, thanks for your question.
      Yes, you can inject parent component in your child the same way as you do it with services. so in your child comp `constructor(private parent: ParentComponent) {}` and then you can call any public method from parent. But I would recommend to do it only when there is no way to use Input/Output

  • @tamil_selvan-eaets
    @tamil_selvan-eaets Pƙed 2 lety +1

    Wow

  • @rahultej8352
    @rahultej8352 Pƙed 2 měsĂ­ci

    the WIDGET token id not provided only below the WidgetWrapper Component, not above. If we If we are following the Injector hierarchy, how is the dependency getting resolved here