mutative icon indicating copy to clipboard operation
mutative copied to clipboard

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

Open araera111 opened this issue 2 years ago • 6 comments

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 avatar Jan 26 '24 01:01 araera111

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 avatar Jan 26 '24 01:01 araera111

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.

araera111 avatar Jan 26 '24 02:01 araera111

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.

unadlib avatar Jan 26 '24 12:01 unadlib

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.

araera111 avatar Jan 26 '24 13:01 araera111

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

unadlib avatar Jan 27 '24 01:01 unadlib

@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.

unadlib avatar Feb 07 '24 17:02 unadlib