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

Remove all action #28

Closed
mecsco opened this issue Dec 5, 2017 · 2 comments
Closed

Remove all action #28

mecsco opened this issue Dec 5, 2017 · 2 comments

Comments

@mecsco
Copy link

mecsco commented Dec 5, 2017

Following on from #26 which mentions @ngrx/entity (https://github.com/ngrx/platform/blob/master/docs/entity/adapter.md) and its support for updating partial data, it may also be useful to have the equivalent of its 'removeAll' action so that all the normalized entities can be cleared out without needing to call RemoveData multiple times with all the individual IDs

I suppose different users might have different requirements - for some it could be to empty everything, for others it could be to specify a certain key and only empty that and all its children (although in that case I guess it could get a bit messy if the children were shared with other parent entities that had a different key that weren't being cleared).

@michaelkrone
Copy link
Owner

For removing child entities, the RemoveData action can take a map of schema keys mapped to property names for entities which should be removed along with the 'parent' entity. Of course this should only be used for 1:1 relations. To remove an entity completely, you might dispatch a SetData action with an empty Array.

@mecsco
Copy link
Author

mecsco commented Dec 5, 2017

Ah understood - I think SetData should cover my scenario, I'll close this ticket

@mecsco mecsco closed this as completed Dec 5, 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

No branches or pull requests

2 participants