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 patchState method to the ComponentStore #2786

Closed
markostanimirovic opened this issue Nov 13, 2020 · 1 comment · Fixed by #2788
Closed

Add patchState method to the ComponentStore #2786

markostanimirovic opened this issue Nov 13, 2020 · 1 comment · Fixed by #2788

Comments

@markostanimirovic
Copy link
Member

Add patchState method to get rid of unnecessary state spreading and replace:

// case 1
this.moviesStore.setState(state => ({
  ...state,
  movies,
}));

// case 2
this.moviesStore.setState(state => ({
  ...state,
  movies: [...state.movies, movie],
}));

with:

// case 1
this.moviesStore.patchState({ movies });

// case 2
this.moviesStore.patchState(state => ({
  movies: [...state.movies, movie],
}));

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

@alex-okrushko
Copy link
Member

@markostanimirovic
Ok, let's look into it. 🙂

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

Successfully merging a pull request may close this issue.

3 participants