1

ie.

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

I'm curious because easy-peasy uses a Proxy on the store object (and objects nested within) so that in your action you can safely mutate the state object directly (https://easy-peasy.now.sh/docs/tutorials/primary-api.html#modifying-the-state). I don't know if this also works when using non Plain Old JavaScript Objects, such as Maps.

Joel M
  • 353
  • 2
  • 10

1 Answers1

1

It looks like this is possible on certain versions, but not without first declaring support for the feature (so the code above will not work right out of the box, as of now). See here for more info: https://github.com/ctrlplusb/easy-peasy/issues/440

Joel M
  • 353
  • 2
  • 10