undux icon indicating copy to clipboard operation
undux copied to clipboard

Is it possible to update partial values?

Open mironal opened this issue 7 years ago • 2 comments

Hi! Thank you for a wonderfully simple and type-safe library. 😄

I thought about this kind of things. Currently, it seems that I can not set without passing all the properties to set, but I'd like to update the value for partially.

For example, I would like to write the following code.

interface Some {
    one: string
    two: string
}

interface AppStore {
     some: Some
     other: string
}

store.set("some")({one: "hoge"}) // <- Is this possible? Do you have plans to make it possible if you can not? 

mironal avatar Apr 25 '18 03:04 mironal

Hey @mironal! No plans to do this yet, but let’s keep this issue open in case there’s demand for it.

You might also consider using a spread as simple syntactic sugar to do this, or something like ImmutableJS to help do these deep updates.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

https://facebook.github.io/immutable-js/

bcherny avatar Apr 25 '18 03:04 bcherny

OK! Thanks for your very quick response!

mironal avatar Apr 25 '18 03:04 mironal