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

Proposal: add produce, which is an ALIAS of create. #32

Open
araera111 opened this issue Jan 26, 2024 · 6 comments
Open

Proposal: add produce, which is an ALIAS of create. #32

araera111 opened this issue Jan 26, 2024 · 6 comments

Comments

@araera111
Copy link

The basic syntax is the same, so when changing from immer to mutative, it is only necessary to replace the import statement.

I haven't looked at the source code, but I think it would be as simple as adding the following one sentence.

export const produce = create;
@araera111
Copy link
Author

import statement of immer in v9

import produce from "immer";

import statement of immer in v10

import { produce } from "immer";

If produce can be used instead of create, it will work for most patterns for v10 immer that do not use immer's special features.

@araera111
Copy link
Author

araera111 commented Jan 26, 2024

I read the documentation and learned that there is a wrapper called mutative-compat. Sorry for creating the issue without reading the documentation.

However, I also feel that my project does not want to add the wrapper as a dependency.

Install mutative and change the import statement.
It is easy if that is all it takes to complete the migration.
We believe that the number of users will increase.

@unadlib
Copy link
Owner

unadlib commented Jan 26, 2024

How do you feel about adding such an API for quickly migrating from Immer to Mutative?

- import { produce } from "immer";
+ import { produce } from "mutative/migrate-immer";

It is important to note that Immer and Mutative have significant differences in their configurations, and therefore they cannot be considered completely equivalent.

@araera111
Copy link
Author

I think it is an excellent proposal.
If implemented, it would make the transition easier.

I think a lot of people, myself included, are using just "produce". I think it would be great if just changing the library would increase the processing speed.

@unadlib
Copy link
Owner

unadlib commented Jan 27, 2024

hi @exuanbo , it might be possible to implement a migration API similar to mutative-compat in Mutative. What are your thoughts on this?

@unadlib
Copy link
Owner

unadlib commented Feb 7, 2024

@exuanbo I'll probably be working on the proposal using mutative-compat over the next few days. If you've got any thoughts or feedback, don't hesitate to reach out anytime.

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