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
Is there a reason there's no public API to convert an Ember.Object back to a native JS object #10875
Comments
I guess it just depends on how you're using the framework. I personally have never found this need, the only time I can imagine wanting this would be for object serialization and I use ember-data, so that need is not relevant. That said, if I did have this problem, I would start by using |
this is what feel free to use, Ember.keys(Ember.Object.create({ foo: 1 }))
> [ 'foo' ] |
I would likely recommend against this, why not just use the |
@stefanpenner I think that's really a question for the OP. I guess I was assuming that he had a class that had computed properties/functions/observers/etc. I had not considered just iterating with Just out of curiosity, why would you recommend against using Edit: Just to clarify, the |
There are a few strategies to extract the original "Hash" structure that was used to create the ember object (with or without modified values), my question was mostly about how often the general Ember.js community needs this. a One concrete example, if you're curious, is using an One last reason I do this a lot is to create a deep copy since implementing |
The biggest reason for needing pojo's is for 3rd party library support. Datatables, jstree, etc. all expect plain javascript arrays and objects and will blow up with ember data structures. |
@ccarterc like, e.g. localforage.setItem - it is PITA with Ember.Object |
Ran into this exact need today. As @ccarterc said, this is crucial for 3rd party libs that are expecting POJOs. It would be great to have an "official" method to do this. |
I want the ability to work with a POJO, so I can send my object into a 3rd party vanilla JS library. |
yes please - struggling with this now for a 3rd party api. my current workaround is to do |
I find myself needing this a lot and I'm wondering if there is rationale behind why this hasn't been added to the framework.
I would think the use cases would be plentiful and obvious. An Ember.Object adds a LOT of metadata and extra properties to a plain object, so if you ever want to operate on an object with a generic function that iterates over an object's properties, those properties really get in the way.
The text was updated successfully, but these errors were encountered: