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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to update partial values? #22

Open
mironal opened this issue Apr 25, 2018 · 2 comments
Open

Is it possible to update partial values? #22

mironal opened this issue Apr 25, 2018 · 2 comments

Comments

@mironal
Copy link

mironal commented Apr 25, 2018

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? 
@bcherny
Copy link
Owner

bcherny commented Apr 25, 2018

Hey @mironal! No plans to do this yet, but let鈥檚 keep this issue open in case there鈥檚 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/

@mironal
Copy link
Author

mironal commented Apr 25, 2018

OK! Thanks for your very quick response!

@bcherny bcherny removed their assignment Jul 2, 2018
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

2 participants