Skip to content

Avoid suggesting using data directly #35

@makepanic

Description

@makepanic

I don't know if this is something that should be mentioned in the readme but data is private api and shouldn't be used.

I got stung by it after using the data links directly in my templates for using a media link that is rendered in an image, i.e. {{my-image src=obj.nested.data.links.media}}.

The problem is that the data, which is an readonly alias for its internal model _data is converted by ember to an ember object with __ember_meta__, setters, getters and much more. That means the internal model is now an ember object (which is pretty bad).

This breaks pushing an already loaded record to the store (i.e. by ember after an store.find) because it tries to merge the stored record with the new incoming record. This happens without calling Ember.set which causes the ember added setter to throw an error because it needs to be invoked with Ember.set

20150818-130854

I solved this for myself by adding a links attribute links: attr() to all my models and reading the links values from that attribute. ({{my-image src=obj.nested.links.media}}).

This could be redundant if warp-drive-data/warp-drive#2905 is fixed (warp-drive-data/warp-drive#3419)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions