ultimatecourses/ngrx-store-effects-app

Lifecycle for initializing selectors - preference? Or are there technical differences?

Closed this issue · 2 comments

Is there any difference/ reason for location of selectors in ngOnInit vs. in the constructor?, i.e.,
this.toppings$ = this.store.select(fromToppings.getToppings)

Seeing them in the constructor in the example app and in ngOnInit in this repository. Any meaningful difference or just preference?

I haven't seen any difference using both.

Initialisation is done in ngOnInit and dependencies are injected in constructor making that split IMHO makes it all more readable.

I usually opt for ngOnInit nowadays, little easier/clear for testing purposes when you can invoke the lifecycle hook. :) not a huge difference in reality. Closing off but feel free to continue the convo if necessary! :)