WOW! great example for inject. first time I subscribe after one video watch
@CodeShotsWithProfanis Жыл бұрын
:) That's great! Thanks a lot for the sub and glad you like my content
@owenjaspervargas1408 Жыл бұрын
Good teacher! Easy to understand you deserve more subs!
@CodeShotsWithProfanis Жыл бұрын
Thanks for your warm feedback! :)
@arthurfedotiew36092 жыл бұрын
Thank you master Profanis!) The most valuable one thing to learn from this is that inheritance begins to seem a little more useful now) Btw, inject() in a context of factory provider could be used for a pretty long time, I think when ivy got into a play or so
@CodeShotsWithProfanis2 жыл бұрын
Yeah, the inject() opens so many possibilities. Ohh, thanks for letting me know about the factory! :)
@nfallycoly6362 Жыл бұрын
Awesome, thank you so much!
@CodeShotsWithProfanis Жыл бұрын
You are welcome! :)
@rafaelpanayiotou18332 жыл бұрын
Hello.. thanks for your video...! why i am facing this issue? " NG0203: inject() must be called from an injection context"
@CodeShotsWithProfanis2 жыл бұрын
The inject() method works only during the class construction. Having said that, it's OK to use the inject in the constructor, but it's too late if you try to use this in the ngOnInit hook. The inject requires the initialization context, which is available only during the class construction.
@antt00232 жыл бұрын
How did you make the param name to show on vscode? Like in the logger token, it shows _desc as param name. Really helpful video. Thanks man
@CodeShotsWithProfanis2 жыл бұрын
I really like the feature with the argument names :) Add this in your settings.json: "typescript.inlayHints.parameterNames.enabled": "all" Glad you liked the video!
@fahadgaliwango45022 жыл бұрын
Thak you profanis . Have understood it as way to reduce dependecies in the constructor , so they can be declared as global functions or variables, is that a correct take home
@CodeShotsWithProfanis2 жыл бұрын
Yes it's a way to have utility functions, create more abstractions. It offers a great flexibility.
@harunmn2 жыл бұрын
awesome explanation! thanks
@CodeShotsWithProfanis2 жыл бұрын
Thanks for your feedback. Glad you liked it!
@ThodorisHadoulis2 жыл бұрын
Really insightful!
@CodeShotsWithProfanis2 жыл бұрын
Glad you liked it!
@hadirahmani79432 жыл бұрын
that was very powerful, thanks so much
@CodeShotsWithProfanis2 жыл бұрын
Glad you liked it! :)
@paulh69332 жыл бұрын
awesome info
@CodeShotsWithProfanis2 жыл бұрын
Glad you liked it Paul
@orshalmayev70772 жыл бұрын
This is usefull. Thank you!
@CodeShotsWithProfanis2 жыл бұрын
Thanks for your feedback and glad you liked it! :)
@OlehBiblyi2 жыл бұрын
Thank you, very interesting, I think I need to repeat a lot of stuff about Class, to properly understand what is going on here ). Also what is a difference between take(1) and first()?
@CodeShotsWithProfanis2 жыл бұрын
The difference between take(1) and first() operators is in the emitted value. If you use the first() operator and the stream completes without any emitted value, then an error is thrown. However, the take(1) will complete the stream without error. I hope this helps
@OlehBiblyi2 жыл бұрын
@@CodeShotsWithProfanis Thanks a lot!
@seanpheneger66322 жыл бұрын
Pluck is being deprecated. You should update to use map operator
@CodeShotsWithProfanis2 жыл бұрын
Ohh yeah, indeed! rxjs.dev/api/index/function/pluck Thanks for pointing out this
@seanpheneger66322 жыл бұрын
Yeah, sure thing. I used it a lot in a few of my older projects but have been updating any new files to use map now so it'll be less painful of a migration when it is fully removed. Thanks for the video. It was insightful.
@diyvideos97372 жыл бұрын
Thanks
@XHANITRUNGUMANOS2 жыл бұрын
Hello . I would like to add that we can use the Inject method in any other hook or lifecycle , except from constructor utilizing the power of closures, as we are able to store the injected token inside the closure scope and still use values in the returned function. 😁😁😁| exort const dispatchSearch = (): ((search: string) => void) => { const store = inject(Store); return (search) => store.dispatch(new SetSearch(search)) }
@zshn2 жыл бұрын
Well, that's a mess. inject() anywhere and everywhere. Peer Reviews, debugging and defect fixing are going to be more fun.
@jonasjanaitis4362 жыл бұрын
I spen half a day figuring out what a hell is going on. In one code I found this implementation: constructor(@Inject(HttpClient) private http: HttpClient). But this constructor for me always returned undefined...I think it worked in older versions of Angular. At least now I can go to sleep in relief, thank you
@CodeShotsWithProfanis2 жыл бұрын
Both inject and @Inject are valid per case. In case you want to use the HttpClient in your constructor, you can even do constructor(private http: HttpClient) {}
@jonasjanaitis4362 жыл бұрын
@@CodeShotsWithProfanis I have Rest class that is not marked as @Injectable but it is like an abstract class. Then I have two services that extend that Rest class and is marked as @Injectable and these services are in provider[]. Rest class has HttpClient, but as I said before it always returns undefined when I do constructor(@Inject(HttpClient) private http: HttpClient) in Rest class. But http:HttpClient = inject(HttpClient) works fine.