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

List.delete() returns an empty array #1901

Open
fork88888 opened this issue Apr 21, 2022 · 4 comments
Open

List.delete() returns an empty array #1901

fork88888 opened this issue Apr 21, 2022 · 4 comments

Comments

@fork88888
Copy link

fork88888 commented Apr 21, 2022

Dear developers.

I'm using Immutable.js v4.0.0 with Vue 3.2.29 + typescript

The arrayOfItems.value is a List of objects and it contains 7 items and the index variable is 5.
If I run the following code:

arrayOfItems.value = arrayOfItems.value.withMutations(x => {x.delete(index);});

then I get the empty array instead of the array that excludes object by index only. arrayOfItems.value and x will be equal [] after invoking delete. The behaviour of remove method is the same.
It seems that its a wrong behaviour.

@georg-getz
Copy link

georg-getz commented May 10, 2022

I have the exact same problem, version is 3.8.2.

P.S. remove is an alias for delete, that's the reason they are both bugged.

@jdeniau
Copy link
Member

jdeniau commented May 16, 2022

Hi !

I do not know why for now, but in the delete documentation, you can read that:

Note: delete cannot be used in withMutations.

So it's not considered as a bug. But we should either authorized this, if possible, or improve de DX there.

You can see Lee's response here : #228 (comment)

@georg-getz
Copy link

Hi @jdeniau
I followed the issue you linked and it seems people were confused about this behaviour 8 years ago as well and all that changed was that the note you quoted was added to the docs. Is it safe to assume that delete/remove will never work with withMutations/asMutable?

@jdeniau
Copy link
Member

jdeniau commented May 17, 2022

@georg-getz If you have another solution (like not using withMutation), I suggest you to take that solution 😉

I do not know that exact part, but as Lee only updated the doc, I think that it might be really difficult to make it work.

I think that a possible "solution" may be to log a warning or mark this comportment as @deprecated or somethink like that though.

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

No branches or pull requests

3 participants