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

Descructuring with spread operator (immutable.js) #10

Open
savelichalex opened this issue Mar 24, 2016 · 6 comments
Open

Descructuring with spread operator (immutable.js) #10

savelichalex opened this issue Mar 24, 2016 · 6 comments

Comments

@savelichalex
Copy link

For example:

function foo() {
  return new Map({foo: 1, bar: 2});
}

function baz({foo, bar}) { ... }

baz(...foo())

not work. Need to do baz(...foo().toJS())

@tomaskulich
Copy link
Contributor

Thank you, I'll see to it.

@tomaskulich
Copy link
Contributor

well, I thought about this a little, and it seems to me, it's far from clear, what semantics should 'extensible spreading' have. Given that Map map is deeply immutable structure, what should

{...map, key: val} 

be? It should probably be js object, but what about the values in map? Should they be also recursively jsified?

Another problem I see is, that such proposal would require more patching (defining just __extensible_get__ is obviously not enough)

@savelichalex
Copy link
Author

I think that should be jsified only first level of Map

@jonathanj
Copy link

What about spreading an Immutable Record? I was sort of expecting it to work because Record({a: 1}).a is defined, whereas for a Map it isn't; but it doesn't work. I think spreading an Immutable Record is probably pretty clearly defined though.

@palnes
Copy link
Contributor

palnes commented Feb 21, 2018

@jonathanj i'm not so sure. an Immutable.Record does not expose its keys in any meaningful way, except if you turn it into an Immutable.Map.

@highfield
Copy link

I can confirm that it's not working. However, the "toJS"-way seems a (temporary) patch.

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

5 participants