CanLoad Guard in Angular Router & Preloading Strategies (2021)

  Рет қаралды 12,195

Decoded Frontend

Decoded Frontend

Күн бұрын

Пікірлер: 40
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Do not forget to leave your honest feedback! I hope you will find something useful in this video :) Enjoy!
@aleksandrm3466
@aleksandrm3466 3 жыл бұрын
This is the Best Angular channel. Thanks alot for your work, I am already waiting for the new video :)
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Thanks a lot for the feedback! I appreciate it!
@gururajmoger8649
@gururajmoger8649 3 жыл бұрын
Pls explain more stuff in angular
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
I will :)
@pavelbolshakov9799
@pavelbolshakov9799 Жыл бұрын
The most useful and understandable KZbin channel about Angular. Dmytro handsome💪
@rs4267
@rs4267 9 ай бұрын
Greatest angular channel ! I didn't get the use of fn method in preload
@pastagaz4241
@pastagaz4241 3 жыл бұрын
Awesome to see you talking about preloadStrategies. I have created a custom one on our project, with a pretty good option: it preload module only when user ‘mouseOver’ a menu link, with an array that save all preloaded modules to prevent trying to reload again.
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Great idea! :) and there is also a library by Minko Gechev github.com/mgechev/ngx-hover-preload You might find it interesting
@andresmauriciofajardoolaya2721
@andresmauriciofajardoolaya2721 3 жыл бұрын
I was waiting for this video, thanks :)
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Enjoy! :)
@manojojha68
@manojojha68 2 жыл бұрын
Can you please make video on Component life cycle hooks and ChangeDetectionStrategy?
@bromptonhorsing8597
@bromptonhorsing8597 3 жыл бұрын
Great video, as always It'd be really cool to see a video about import management (avoiding circular dependencies, yet having your imports not being ugly :) )
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Nice idea! Thank you
@yt.mhasan
@yt.mhasan 2 жыл бұрын
@@DecodedFrontend Any video on that yet?
@DecodedFrontend
@DecodedFrontend 2 жыл бұрын
@@yt.mhasan Not yet, sorry :(
@abdouafailal4869
@abdouafailal4869 3 жыл бұрын
Amazing work
@shibinjohn2792
@shibinjohn2792 3 жыл бұрын
Very helpful content. ❤ Much love brother🧡
@sahilvig8014
@sahilvig8014 2 жыл бұрын
Can you please create some videos on angular testing.
@booaboo2240
@booaboo2240 3 жыл бұрын
this is what i looking for, buds! i have just started to learn about angular and so far i need a story to make my angular journey more understandable (since i am not a native EN also it is quiet hard to understand strange words in readable tutorial at angular.io). i always waiting for your vids :)! ps: i just a little bit having rough time to understand about http interceptors and it's usecase. mind you create that content here? or if you did, mind you to provide your video link so i can watch it? thanks in advance
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
I didn't do it yet, but I will :) Thank you for the feedback and suggestion!
@playful_creations
@playful_creations 2 жыл бұрын
This is best channel. Can you please make video on component lifecycle hooks?
@only_one_chance
@only_one_chance 3 жыл бұрын
​Hey dude, Love your channel. Thanks for such great content. How about creating some portion on videos about ng-template, using templateRef, directives and components using ng-template etc. I think many people do a lot of mistakes using this techniques especially when creating embedded view through the controller. Thanks
@pawansahu8605
@pawansahu8605 3 жыл бұрын
nice explanation 👍, please create one video for how to implement openId, authentication and authorisation related topics 😊
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
One day I will :)
@Maryna768
@Maryna768 3 жыл бұрын
thanks for the great content!
@kavyashreebj5848
@kavyashreebj5848 3 жыл бұрын
Hey Dmytro, thanks for all the awesome concepts! Could you please make one on the difference between changeDetectionStrategy.OnPush v/s ChangeDetectorRef.detach() ?
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Yes, it will be sooner or later :) thank you for suggestion
@dragorwyin9809
@dragorwyin9809 3 жыл бұрын
00:07:52 Hey Dmytro! Awesome content as always. My little suggestion - You have a typo in "Subscribe to the *chanel* ". Should be *channel* instead :).
@rihardkrauz4696
@rihardkrauz4696 3 жыл бұрын
So and what is the difference between purposes of canLoad guard and AuthPreloadingStrategy? Because both of them are doing the one thing - should we load lazy module or not. Maybe do you know any real-life examples of usages?
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Hi Rihard, I see your confusion. Well, those 2 are solving different issues. The Guard "CanLoad" is being involved for only one concrete route ("/admin") and it is being resolved only at that time when user navigates to that route. The Preloading Strategies happens immediately when Angular App bootstraps and it is being applied for all Lazy Modules in the App. Also, if you do not allow to preload modules it doesn't mean that it can't be loaded at all, only CanLoad takes this decision if it is allowed/prohibited to load some certain module. You may reasonably ask "Why do we need preloading at all?" and we need it because loading of heavy modules may take some time and it might be visible to the user as some glitch or freezing, so preloading allow you to preload the module in background before user navigate to the lazy module. If we use an example from video there will be next scenarios: CanLoad: User navigates to a route => CanLoad guard is involved => if user logged in (true) => load the module for this particular route. AuthPreloadingStrategy: User enters the App => AuthPreloadingStrategy is involved => if user logged in (true) load all lazy loaded modules in the app. In this particular case we consider that any loggedIn user is an admin, so it make sense to preload AdminModule only if user authenticated because if it is a regular user it makes no sense to preload AdminModule and waste user's internet traffic because user will never reach the admin section. I hope I made it somehow clearer :)
@Sevkingblade
@Sevkingblade Жыл бұрын
So it's like CanMatch for lazy-loaded routes. Might be an over simplification the way I said it but kinda like that
@pawansahu8605
@pawansahu8605 3 жыл бұрын
super like 🙏
@DjokovicAirlines
@DjokovicAirlines 3 жыл бұрын
Hi, thanks for the video. It's really helpful. But I have a question: For example, you are at 'home' route and there you have a button 'personal profile' which leads to either 'auth/login' or 'personal/profile' (depending on your login status). Each route (auth/... && personal/...) has separated module file (auth.module and personal.module) with lazy loading. If I'm not logged in and I press 'personal profile' button - it relocates me to 'auth/login'. So is it loads auth module or both auth and personal modules?
@MK-we4dl
@MK-we4dl Жыл бұрын
Сенсей, помогите пожалуйста! При релоаде гвард отробатывает ДО загрузки проверочных данных в сервисе. По дереву загрузка даже не доходит до защищенного роута и переходит в корень "/". Первый грузится главный компонент и загружает данные, после чаилды с проверкой гварда по признаку из данных которые загрузил родительский компонент. При навигации всё отлично, но если сделать релоад то ничего не отрабатывает. Мотули лейзи, прелоад PreloadAllModules, гвард в провайдерах модуля с сервисами и компонентами версия 13.
@yevhen3934
@yevhen3934 3 жыл бұрын
Hello Dmytro! It's a great and helpful video! We are very grateful for your activity and work. You help us a lot to understand difficult topics. Good luck to you! It would be cool if you tell us about Smart and Dumb components. For example, a situation where we have many nested child components and if we want to transfer data from the deep child component to the parent, an "event emmiting hell" is formed . Someone suggest using a service with Subjects so that the parent subscribes to the stream and listens to these events of the deep child component. If we have a large project, then many services and subjects need to be created for this. I don't know if this solution is the best for such a case. What do you think about this? Also, I have one question and it would be great pleasure to hear your opinion. Let's consider the following situation. We have a large Angular project. We have components that include styles in the @Component decorator. If we build the project, then our bundles will include these styles. Our styles will be in *.js files. As a result, we will have a project size of ~2 megabytes, as an example. But, if we move our styles from components to global styles, using global classes in the components, and removing this binding in the @Component decorator, then after the project is built, they will be in *.css files. And the project will become ~1.7 megabytes in size, also as an example. We can call this project optimization. But we have a stupid project architecture. Now our styles aren't attached to the components. But is this optimization worth it? We do not adhere to the principles of Angular itself, as it seems to me. Some kind of confusion is going on. It was provided that in Angular a component is a template, styles and *.ts file. Why am I asking for your opinion here? We have a project, and the senior dev has implemented it in the second described way, i.e. he brought all the styles from the components to the global styles and put them all in the assets folder. As a result, they will be imported into the style.css file, and they won't be in the javascript files after the build. For some reason it is disgusting to me 😁 But still we do not break the rules - styles in styles, javascript code in js files. How do you find the perfect solution? Have we to write our own Webpack config for Angular?
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Hi Yevhen, Thanks for your feedback! Regarding you question about smart/dump components. This pattern doesn't claim that Dump component must contain ONLY dump components, so in your case maybe it would make sense to introduce a new "container" somewhere in the middle and then you would not need to propagate event through entire component tree? Regarding styles. When you move styles from Component to global styles.css you break style encapsulation which I find not really good especially for big projects. I have heard that indeed encapsulation.none may decrease a final bundle but I doubt that this win worth it because your style become fragile and easy to break which is more visible for the user comparing to increased load speed up to 100-200ms :) Also keeping styles out of component folder leads to a situation when you just forget to clean up styles when you remove some component and you end up with a lot of dead-code, so I would recommend at least to keep styles file in the same folder with a component, but tbh I would disagree completely with the 2nd solution you described. I would agree if to the global styles could be extracted "theming styles" which are responsible for colors, typography, density etc. and it is basically how Angular Material forces you to do. P.s However, there is no perfect solution here and you should take a decision in your team on your own and to not rely on my thoughts too much because ultimately nobody knows the project better than you.
@yevhen3934
@yevhen3934 3 жыл бұрын
@@DecodedFrontend Damn, your words are brilliant! I'm happy that you answered my comment :) You're right about the Smart/Dumb components. Thanks for the advice on how to solve the given problem, it will help me a lot in the future! Your arguments are strong and have helped me build a strong position. It was difficult for me to form a thought that could be a weighty argument in that case. Now this gave me an idea of how to do it right. I completely agree with you and I am very grateful to you for your time! Have a nice day!
@ВаноВано-л6р
@ВаноВано-л6р 3 жыл бұрын
Красавелла!!!
@DecodedFrontend
@DecodedFrontend 3 жыл бұрын
Хаха)) спасибо 😉
Resolver Guard in Angular Router (2021)
16:24
Decoded Frontend
Рет қаралды 28 М.
CanDeactivate Guard in Angular Router (2021)
25:56
Decoded Frontend
Рет қаралды 15 М.
Structural Directives in Angular - How to Create Custom Directive
16:59
Decoded Frontend
Рет қаралды 28 М.
Input Signals in Angular 17.1 - How To Use & Test
14:34
Decoded Frontend
Рет қаралды 31 М.
Angular Dependency Injection in Depth - Resolution modifiers (2021)
14:39
What's new in Angular
39:19
Chrome for Developers
Рет қаралды 24 М.
CanMatch Guard in Angular 14.1 Router (2022)
17:49
Decoded Frontend
Рет қаралды 15 М.
APP_INITIALIZER Token in Angular (Advanced, 2022)
23:56
Decoded Frontend
Рет қаралды 22 М.
NgTemplateOutlet in Angular - Everything You Have to Know (2022)
35:15
Decoded Frontend
Рет қаралды 54 М.
Angular CanMatch Route Guard | Why is CanLoad deprecated?
8:15
Web Tech Talk
Рет қаралды 2,4 М.
RxJs switchMap vs mergeMap - Intro to Flattening Operators (2021)
25:44
Decoded Frontend
Рет қаралды 30 М.