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

Does the store Proxy work for non plain old javascript objects like Maps? #646

Closed
j-masci opened this issue Apr 1, 2021 · 2 comments
Closed

Comments

@j-masci
Copy link

j-masci commented Apr 1, 2021

ie. Would there be any problems to doing things like this (sorry for my opinionated comment about the setter):

const store = {
    values: new Map(),
    // (gross trivial accessor)
    setValue: action( (state, payload) => {
        state.values.set(payload.key, payload.value);
    }
}

https://stackoverflow.com/questions/66910556/can-you-use-a-map-instance-as-an-easy-peasy-store-property

I didn't find anything in the docs for this. It just had some arrays as examples. In addition, I had to confirm myself that it worked properly on nested POJO's because the docs, which mentioned immer and Proxy's did not go into much detail about this. Perhaps the documentation can be clarified. Thanks. (https://easy-peasy.now.sh/docs/tutorials/primary-api.html#modifying-the-state)

@jmyrland
Copy link
Collaborator

jmyrland commented Apr 1, 2021

Hey! I found this discussion: #440 (comment)

It might provide some answers 👍

@j-masci
Copy link
Author

j-masci commented Apr 1, 2021

Ok, perfect, thanks.

So it looks like it is possible but you have to declare support for it. (If you want to know how, check the link above).

@j-masci j-masci closed this as completed Apr 1, 2021
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