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

Introduce dynamicObject for dynamically keyed objects in Proxy supporting environments #652

Closed
mweststrate opened this issue Nov 13, 2016 · 5 comments

Comments

@mweststrate
Copy link
Member

See also #336

Introduce object = dynamicObject(object) and implement that using ES6 proxies. This allows plain objects to be used as observable objects, without the current limitation of not supporting dynamic keys.

I think that is a nice case to start working with Proxies, learn about their caveats, performance etc. It has a clear use case and advantage over the current getter / setter implementation, yet there is a fallback for those needing to support browsers without proxies (probably the most of us): ObservableMaps

Example:

const todos = dynamicObject({
  "a23bf": { completed: false}
})

autorun(() => console.log(Object.keys(todos)))
// prints "a23bf"

todos["a8235"] = { completed: true}
// prints "a23bf", "a8235", something that currently can only be achieved through observable maps

Should throw clear error if proxies (or too limited polyfill) are not available at runtime and hint at using ObservableMaps instead

@mweststrate mweststrate changed the title Ìntroduce dynamicObject for dynamically keyed objects in Proxy supporting environments Introduce dynamicObject for dynamically keyed objects in Proxy supporting environments Dec 28, 2016
@amir-arad amir-arad mentioned this issue Jan 17, 2017
@mull
Copy link

mull commented Mar 23, 2017

Did anyone start working on this yet?

@amir-arad
Copy link

I have #776 with pending tasks, but it's not going to get any serious boost from my end

@ascoders
Copy link

ascoders commented May 22, 2017

Hi @mweststrate , I implemented mobx in proxy, although not all of the API has been implemented, but the core functionality has been opened and has passed 50 unit tests and has been run online.

code: https://github.com/ascoders/dynamic-object

@ascoders
Copy link

And implemented a similar mobx-react called dynamic-react, i wish I could merge into mobx

@mweststrate
Copy link
Member Author

@ascoders didn't see the comments earlier, thanks! Will check the code out when starting on proxies.

Closing this issue now in favor of #1076

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

4 participants