unadlib / mutative

Efficient immutable updates, 2-6x faster than naive handcrafted reducer, and more than 10x faster than Immer.
http://mutative.js.org/
MIT License
1.53k stars 16 forks source link

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

Open araera111 opened 5 months ago

araera111 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

unadlib commented 4 months ago

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