-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
docs: fix selection of state using arrow function #261
Conversation
The select method from the Store expects a function, when I put the `this.counter = store.select<number>('counter');` the compiler says: `Argument of type '"counter"' is not assignable to parameter of type '(state: AppState) => string'.`
docs/store/README.md
Outdated
@@ -96,7 +96,7 @@ export class MyAppComponent { | |||
counter: Observable<number>; | |||
|
|||
constructor(private store: Store<AppState>) { | |||
this.counter = store.select<number>('counter'); | |||
this.counter = store.select<number>((state: AppState) => state.counter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove the string selector, remove the <number>
type instead. You can't use the generic type with the string selector, which is the cause for the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were right @brandonroberts , I guess it is easier for new comers to select state using the string
selector instead of the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix example
The generic type is not necessary and causes error in compilation because it expects the state key instead of the state key type.
Thanks! |
…)" This reverts commit ca544dd.
The select method from the Store expects a function, when I put the
this.counter = store.select<number>('counter');
the compiler says:Argument of type '"counter"' is not assignable to parameter of type '(state: AppState) => string'.