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

RFC: Provide a message when selectId is undefined #1133

Closed
timdeschryver opened this issue Jun 15, 2018 · 1 comment
Closed

RFC: Provide a message when selectId is undefined #1133

timdeschryver opened this issue Jun 15, 2018 · 1 comment

Comments

@timdeschryver
Copy link
Member

I think if we would log (or even throw) a message when selectId returns an undefined when using Entity module, it would increase the dev experience.
Note that this would only be done when the application is in dev mode.

This message could be something like "ngrx/entity: the key 'id' does not exist in {...}, you can provide your own key with selectId." where id is the return value of selectId. The second part would only be needed if the developer doesn't override the default function.

Describe any alternatives/workarounds you're currently using

Now the developer has to figure out why the ids in the store are all undefined.

Other information:

This idea came after a question and discussion with @sandangel on the gitter channel.

If accepted, I would be willing to submit a PR for this feature

[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

@sandangel
Copy link
Contributor

My idea is extending the capabilities of ngrx/entity by allowing non-unique items in entities. If the id property was not provided, we can add id property = index and entities will look something like this:

{
  '0': {id: '0', data: 'same-data'},
  '1': {id: '1', data: 'same-data'}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants