Uh oh!
There was an error while loading. Please reload this page.
RFC: Pass through attribute meta data to related Transform - #1
Closed
knownasilya wants to merge 1 commit into
Closed
RFC: Pass through attribute meta data to related Transform#1knownasilya wants to merge 1 commit into
knownasilya wants to merge 1 commit into
Conversation
annismckenzie
commented
Oct 27, 2014
+1 |
fivetanley
commented
Jan 6, 2016
Member
I like this a lot and seems good. @igorT thoughts? |
workmanw
commented
Jan 6, 2016
👍 |
fivetanley
commented
Jan 6, 2016
Member
This was approved for implementation at the core team meeting. I'll be the champion, but if someone wants to be the implementer let me know. You might get to it faster. :) |
knownasilya
commented
Jan 6, 2016
ContributorAuthor
First RFC and over a year later! There is always hope! 👍 |
knownasilya
commented
Jan 18, 2016
ContributorAuthor
@fivetanley should this be merged in? Or is that after implementation? |
fivetanley
commented
Jan 18, 2016
Member
Let's wait til after implementation. Seems easier to track. |
pangratz
commented
Jan 27, 2016
Member
Added via 85ef99c |
chancancode pushed a commit
that referenced
this pull request
Oct 27, 2017
Add drain, and link to WIP implementations.
Merged
runspired added a commit
that referenced
this pull request
Jan 16, 2019
Adding proper @ember-data package name where missing
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Would love comments! cc @igorT, @fivetanley
(RFC content pasted in by @machty)
Summary
For Ember Data. Pass through attribute meta data, which includes
parentType,options,name, etc.,to the transform associated with that attribute. This will allow provide the following function signiture updates to
DS.Transform:transform.serialize(deserialized, attributeMeta)transform.deserialize(serialized, attributeMeta)Motivation
The main use case is to be able to configure the transform
on a per-model basis making more DRY code. So the transform can be aware of type and options on
DS.attrcanbe useful to configure the transform for DRY use.
Detailed design
Implementing
The change will most likely start in
eachTransformedAttribute, which gets the attributes for that instance viaget(this, 'attributes'). In theforEachthenamewill be used to get the specific attribute, e.g.The next change will be in
applyTransforms, where theattributeMetaparameter is added and passed totransform.deserializeas the second argument.You also have to handle the serialization part in
serializeAttribute, where you pass through theattributeparameter totransform.serialize.Using
A convoluted example:
Drawbacks
Extra API surface area, although not much. This could also potentially introduce tight coupling between models and transforms if used improperly, e.g. not returning a default value if using type checking.
Alternatives
Unresolved questions
Does the whole meta object need to be passed, or do we selectively pass in only the useful properties? Like
optionsandparentTypeandname..