-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
factoryFor
as a public API replacing _lookupFactory
#150
Conversation
Let's please use constructor instead and say it is optional, I think it is ok to register a factory to create an object literal or use Object.create(). |
constructor may have meaning in that position, which is why class was chosen. |
@krisselden regarding registration- You're looking for language that it is acceptable to call |
@mixonic - That protocol (having a |
Seem closely enough related to fold in. Today |
I think the how we teach this section should also mention a migration guide for most of the cases that will break. @rwjblue's example implementation in #125 also seems like it could be added to the RFC. His comment tells the story much better than this 280 line RFC. Could you also add some reduced examples to the drawbacks section? The links towards projects do not always paint the picture of what is meant very clearly. |
@martndemus a migration guide draft seems appropriate here.
😭 which you've asked me to add further details to I'll add a link to his comment somewhere relevant.
There are really not any good use-cases where you need this behavior, so any reduced example would also be pretty contrived. I will attempt to explain what the examples I've linked to are. |
The more ELI5 this RFC is, the more easier it is to crowdsource docs/guides updates. 😄 |
d2bc2fe
to
eccbd06
Compare
I've pushed a round of edits here, much improved. Please give it another look! |
|
||
Currently, factories registered into Ember's DI system are required to | ||
provide an `extend` method. Removing support for extend-based DI in `_lookupFactory` | ||
will permit factories without `extend` to be registered. Instead factories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this change, but it is likely the second "breaking change" in this RFC. Is this a reasonable concern, or is it ok, and if so how do we migrate forwards + minimize any potential fallout. Or do we need more information/use-cases...
I am slightly confused, during what part of the rollout do we actually diverge the inheritance structure to the new simpler form? I don't believe we can doit immedately as usages of |
@stefanpenner this proposal is fairly aggressive in that it suggests removal of the At the same time, this RFC also proposes releasing a polyfill for |
@mixonic this RFC describes the API, but does not describe when we deprecate the internal behavior (the inheritance change). Remember we cannot support both inheritance hierarchies simultaneously. basically, at all times the following should be true:
I suspect we should do the following:
I'm not sure how we can polyfil the inheritance hierarchy switch, although we can polyfil the external API's cosmetically. |
In the meeting we also discussed wrapping
|
@mixonic / @rwjblue I (well actually @krisselden) have found a legit in-the-wild example of my concern raised in chat yesterday, on how we will end up breaking real code by no longer calling I remember we at-least used to do this often, but couldn't remember a current scenario. One work-around would be to only not call |
I would not be surprised if there is not addons that use extend to return a custom factory |
Yes, i believe we can detect those cases and do the old thing. |
To help this RFC along, our team is desperately trying to migrate from 1.13. One of the hardest blockers of this is our app design relied heavily on JS only The downsides are:
Although This RFC would offer a sanctioned way to create objects via a factory with dependency injection where the usual ember-data is great that it can do this stuff automagically but it sure is nice to be able to do these tricks on our own. As an addon author it opens up a large opportunity for some very powerful features. I hope this testimony of one possible use case in a production app helps adds some context to this RFC. |
For what it's worth here is how we worked with this (with out the ember-getowner-polyfill): import Ember from 'ember';
const { isPresent, Service, deprecate } = Ember;
function getOwner(ctx) {
deprecate(
'Ember.getOwner() is available now; please cleanup references to this.container',
isPresent(Ember.getOwner),
{id: 'container-lookup'}
);
return isPresent(Ember.getOwner) ? Ember.getOwner(ctx) : ctx.container;
}
export default Service.extend({
createRecord(modelName, payload) {
const owner = getOwner(this);
const lookupFactory = owner._lookupFactory || owner.lookupFactory;
const ModelFactory = lookupFactory.call(owner, `model:${modelName}`);
return ModelFactory.create(payload);
}
}); |
The prior approach was too fast- this edit lays out a less aggressive and more iterative approach.
This RFC is basically in FCP pending the process item of a tweet from https://twitter.com/emberjs and tag. If you've any remaining concerns you believe are missed here, please let me know! |
@mixonic I use As an addon developer I think it will be straight forward to make the upgrade to 👍 |
I would like to propose we don't inject the deprecated container into the instances returned from |
@locks thats for the tagging! @chadhietala Can you say more? There is no "deprecated container" described here. |
Note: To make the Final Comment Period official, we need to announce it here and on Twitter, so we're restarting the period now. This RFC is now entering a "final comment period". This period is intended to focus the community's attention for a final round of consideration and feedback before an RFC is merged. Please carefully consider the implications of this RFC and how it will affect your Ember projects. Now would be a good time to re-raise any concerns that you feel haven't been fully addressed. If no significant blockers are raised by October 7, we plan to merge this RFC and make plans for its implementation. |
Looks like no additional comments came through during the FCP process. Lets do it!!! |
@rwjblue should the "Final Comment Period" label be removed? |
@pixelhandler good call - done. |
See emberjs/ember.js#14360 for the WIP implementation. |
Rendered
Based on conversation from the F2F and with preliminary review and modifications by @stefanpenner, @rwjblue.
Closes #125