Skip to content
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

Merged
merged 2 commits into from
Aug 11, 2017

Conversation

jdjuan
Copy link
Contributor

@jdjuan jdjuan commented Aug 10, 2017

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'.

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'.`
@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.287% when pulling 0044c87 on jdjuan:patch-1 into c409252 on ngrx:master.

@@ -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);
Copy link
Member

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.

Copy link
Contributor Author

@jdjuan jdjuan Aug 10, 2017

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.

Copy link
Member

@brandonroberts brandonroberts left a 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.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.287% when pulling efb0d89 on jdjuan:patch-1 into c409252 on ngrx:master.

@brandonroberts brandonroberts merged commit ca544dd into ngrx:master Aug 11, 2017
@brandonroberts
Copy link
Member

Thanks!

brandonroberts added a commit that referenced this pull request Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants