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: add state reconciler option #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ljbc1994
Copy link
Contributor

@ljbc1994 ljbc1994 commented Feb 1, 2025

What's the feature?

Add a stateReconciler option (plain function) so that the driver loaded state and current state can be merged in a custom way before being dispatched by the REMEMBER_REHYDRATED action. This means we provide flexibility for consumers if they want to deeply merge the state similar to redux-persist.

Example

import { merge } from 'lodash';

rememberEnhancer(rememberConfig.driver, rememberConfig.rememberedKeys, {
   stateReconciler: (currentState, loadedState) => merge({}, currentState, loadedState),
})

Checklist

  • Added test to cover stateReconciler
  • Updated doc in the README for the new option

Covers #7

@ljbc1994 ljbc1994 marked this pull request as ready for review February 1, 2025 15:25
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13089924867

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12824988712: 0.0%
Covered Lines: 207
Relevant Lines: 207

💛 - Coveralls

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