bcherny / undux

⚡️ Dead simple state for React. Now with Hooks support.
https://undux.org
MIT License
1.49k stars 31 forks source link

+ get/1 && set/1 accept an enum #79

Closed English3000 closed 5 years ago

English3000 commented 5 years ago

Hey,

I noticed in the source code you have getState/1. FYI, it isn't listed in the API.

My use case is when I want to get multiple values from the store--I'd prefer not to have to call store.get/1 multiple times. getState/1 does allow for that.

There's also the "write" version of that use case: setting multiple key-value pairs in one function call, by passing an object and then merging.

I'm no expert in TypeScript, so I just added the raw code.

LMK WYT, Alexander

English3000 commented 5 years ago

I actually just started using Undux. So for now, ergonomics!

But I'll let you know if I come across another :wink:


I guess you'd recommend reading multiple values via getState/1.

What about for writing multiple values at once, like one can with React's setState/1?

bcherny commented 5 years ago

@English3000 Sorry for the delayed response. I recommend you stick to .get and .set. Avoid .getState when possible.