Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Spread operator and proxies #39

Open
pkamenarsky opened this issue Apr 3, 2017 · 1 comment
Open

Spread operator and proxies #39

pkamenarsky opened this issue Apr 3, 2017 · 1 comment

Comments

@pkamenarsky
Copy link

pkamenarsky commented Apr 3, 2017

I have the following use case:

let st = {...};  // st is immutable

let stProxy = new Proxy(st, ...);

Now, I would like to use spread syntax to construct a new immutable version of stProxy:

let stProxy2 = {...stProxy, var: value};

However, the stProxy functionality would be lost then.

So what if {...st, ...} desugars to something like that instead:

Object.assign(st.clone ? st.clone() : {}, st, ...);
@sebmarkbage
Copy link
Collaborator

That's an interesting idea but I think that to make this work, the proxy would need to be able to be aware that this is happening. It could be a possible follow up proposal to Proxies to expand on a new hook that would enable this behavior.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants