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

feat(store): add verbose error message for unprovided feature state in development mode #2078

Merged

Conversation

jtcrowson
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #1897

What is the new behavior?

Verbose error message when the developer attemps to access a selector without first registering the state in a module.

In the example-app, if we try to get something from books state on the login page:

export class LoginPageComponent implements OnInit {
  // ...
  constructor(private store: Store<fromAuth.State>, private bookStore: Store<fromBooks.State>) {
    bookStore.pipe(select(fromBooks.getAllBooks)).subscribe(val => console.log(val));
  }
  // ...
}

We get an error that accompanies the javascript "undefined" error that will help alert users to this common mistake:
Screen Shot 2019-08-21 at 12 24 31 AM

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 21, 2019

Preview docs changes for ace90a5 at https://previews.ngrx.io/pr2078-ace90a5/

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 21, 2019

Preview docs changes for 068ed28 at https://previews.ngrx.io/pr2078-068ed28/

@brandonroberts
Copy link
Member

@jtcrowson will you add a test for this?

@brandonroberts brandonroberts added the Needs Cleanup Review changes needed label Aug 22, 2019
@jtcrowson
Copy link
Contributor Author

@brandonroberts good call, added a unit test in fcabf12.

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 23, 2019

Preview docs changes for fcabf12 at https://previews.ngrx.io/pr2078-fcabf12/

@ngrxbot
Copy link
Collaborator

ngrxbot commented Aug 26, 2019

Preview docs changes for 36f8488 at https://previews.ngrx.io/pr2078-36f8488/

@brandonroberts brandonroberts removed the Needs Cleanup Review changes needed label Aug 27, 2019
@brandonroberts brandonroberts merged commit 6946e2e into ngrx:master Aug 27, 2019
jordanpowell88 added a commit to jordanpowell88/platform that referenced this pull request Nov 8, 2019
ActionType is useful for extracting the response type of the new action creators.

feat(store): add verbose error message for undefined feature state in development mode (ngrx#2078)

Closes ngrx#1897

docs(store-devtools): add recipe to exclude store-devtools from the build (ngrx#2073)

Closes ngrx#1521

fix(store): add DefaultProjectorFn to public API (ngrx#2090)

Allows you to fully type the selector without reaching into the src folder

ci: fix filters on tags for publishing to npm and deployment of docs (ngrx#2091)

* refactor(data): use createEffect function instead of @effect decorator
jordanpowell88 pushed a commit to jordanpowell88/platform that referenced this pull request Nov 14, 2019
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.

RFC: More verbose error message for unprovided feature state in development mode
4 participants