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

Add merge reducer option #135

Merged
merged 2 commits into from
Mar 11, 2020
Merged

Add merge reducer option #135

merged 2 commits into from
Mar 11, 2020

Conversation

rowandh
Copy link
Contributor

@rowandh rowandh commented Oct 10, 2019

Adds the ability to define a custom reducer for merging the rehydrated storage state with the store. If no merge reducer is specified, defaults to the current deepmerge on INIT and UPDATE strategy. This shouldn't change any existing behaviour.

Seems like this idea was already proposed in #65 before deepmerge was selected as the default strategy, but it's become pretty obvious that there's no one-size-fits-all solution here.

Resolves issues like #114, #110, #80 and #128 by allowing custom merge reducers to be defined for these use-cases. Resolves issues like #120 by allowing rehydrated state to be updated on any desired action.

See test for an example of a combined merge strategy using both deepmerge and object.assign.

@rowandh
Copy link
Contributor Author

rowandh commented Oct 10, 2019

Ha, failed to go through all open PRs and see that this is a duplicate of #100. It's been open for a year and is stale now so I won't close this just yet.

@BBlackwo
Copy link
Collaborator

BBlackwo commented Mar 3, 2020

Hi @rowandh this looks great. I'm just thinking which is a better name. mergeReducer from this PR or stateMergeFunction from PR #100. Thoughts?

@BBlackwo BBlackwo self-requested a review March 3, 2020 21:50
@rowandh
Copy link
Contributor Author

rowandh commented Mar 3, 2020

@BBlackwo I named it mergeReducer because everyone in ngrx land should be immediately familiar with what that means. I prefer that name, I'm definitely biased though.

@BBlackwo BBlackwo merged commit bfb31dd into btroncone:master Mar 11, 2020
@BBlackwo
Copy link
Collaborator

BBlackwo commented Mar 11, 2020

Thanks for this @rowandh!

I will try and get this bundled into a 9.0.0 release.

@BBlackwo
Copy link
Collaborator

Also, thank you for the very thorough description. Once this is released I will close those issues that you mentioned that this solves.

@BBlackwo
Copy link
Collaborator

Version 9 has been released, including this PR

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.

2 participants