-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document and add example for using "select" #14
Comments
Added example of using the new "select" in the angular-redux-example: private parts$ = null;
private partsInCart$ = null;
constructor(appStore:AppStore, partActions:PartActions, cartActions:CartActions) {
this.parts$ = appStore.select("parts");
this.partsInCart$ = appStore.select(partsInCartSelector); |
You could do something like passing the constructor(private cd: ChangeDetectorRef) {}
ngOnInit() {
this.data.subscribe(() => {
this.cd.markForCheck(); // marks path
})
} This is were working with observables really gives a benefit on performance… |
It would make sense to place all selector functions into separate files. So, you don't have to worry where to find your required data in the state. Just include the respective selector function and use it. A folder named |
Agree about separating selectors into files. Absolutely makes sense. Will do that tomorrow. Re the change detection, I quite like the fact that the observable itself triggers change detection when data flows in and it's all internal to the mechanism. This way it's all handled nicely by Angular without boilerplate code. One other issue I was looking at and didn't find a solution was the state that is used in functions. Look at the |
Why not writing the value to a class property on update? |
That's what it does right now, using a "subscribe" :) |
Yeah, that's what I meant. I didn't looked at the code since yesterday evening. But the night brought me no better solution 😄 I think this is not a bad solution. Why enforcing to use observables everywhere, also when it makes no sense? |
You're right! :) |
Document (in README) and add example (in angular-redux-example?) for using the "select" observable technique
Implementation done in this PR: #12
CC @micha149
The text was updated successfully, but these errors were encountered: