Comments (7)
I tend to agree, it seems like indirection to add a lot of controllerFor
type hooks when that just delegates to the container anyway.
from rfcs.
The main reason that we didn't make lookupFactory
public along with lookup
was that we intend to change the way things work internally with regards to factory injections and while we realize that we will still have to support folks using the current instance._lookupFactory
and container.lookupFactory
we wanted to provide a better public API going forward.
The goal of that refactor is to remove the current requirement that we .extend
the factory being looked up just to perform injections. Instead, we would like to make the system return an object that itself has access to the original factory (non-extended) and all the hash arguments passed to its .extend
so that we can merge those hash args later when we actually call .create
. (FWIW, this is roughly similar to what we do with contextual components).
Some rough pseudo code:
class FactoryWrapper {
constructor(Factory) {
this.Factory = Factory;
this._extendValues = [];
}
extend() {
this._extendValues.push(...arguments);
}
create() {
return Factory.create(...this._extendValues, ...arguments);
}
}
// ...snip...
factoryFor(name) {
let Factory = normalResolverStuffHere(name);
let wrapper = new FactoryWrapper(Factory);
wrapper.extend(injectionsFor(name));
return wrapper;
}
Obviously, there are a number of things missing in my example above, but that should help understand why things are the way they are today...
from rfcs.
I can say that ember-admin was using container.lookupFactory
. We are now having to opt-into a private API in order to get ember-admin on latest versions of ember
from rfcs.
specifically, we use it to find templates: https://github.com/DockYard/ember-admin/blob/04db8d7c86be89a94eae657c3d4c8f7ff3e8e988/addon/mixins/model-records/write.js#L14
Because templates are just factories we have to use this function
from rfcs.
until what @rwjblue lands, that is unfortunately just a reality for now.
from rfcs.
I can say that ember-admin was using container.lookupFactory. We are now having to opt-into a private API in order to get ember-admin on latest versions of ember.
container.lookupFactory
has always been private, but it is/was commonly used. The reason for prefixing with an underscore is exactly to ensure that developers understand that it is a private function. I definitely agree that we want a public version, and tried to lay out my thoughts in detail above.
specifically, we use it to find templates
@bcardarella - Templates can be looked up via owner.lookup
just fine. In fact this is what Ember does internally (see route template lookup and component layout lookup).
from rfcs.
@rwjblue that worked, thank you!
from rfcs.
Related Issues (20)
- V2 addons' build-time integration HOT 4
- Deprecate all of Ember Classic HOT 16
- Build-time configuration of index.html HOT 3
- Deprecate support for Travis CI HOT 6
- Deprecate `ember-mocha`? HOT 2
- Deprecate `ember-export-application-global` addon? HOT 4
- Run Prettier separately in `app` blueprint HOT 9
- Deprecate `app.import`
- Thoughts on this more ergonomic way to wire up the owner + destroyable association? HOT 2
- Explore "official" pod deprecation HOT 19
- {{else}} should render a value rather than be a control-flow keyword. HOT 5
- new primitive: transition, similar to modifiers, except they block certain render events HOT 2
- Numbers in PR titles affect automation
- Asset import spec RFC HOT 2
- Implement import spec RFC HOT 1
- Replacing `moduleName` in template meta HOT 11
- Simplified imports for common built-in modules HOT 2
- Pre-RFC: Add `aria-current` attribute to Ember's `LinkTo` component HOT 1
- Whitespace handling for `<template>` tag HOT 4
- Add LICENSE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfcs.