Code Monkey home page Code Monkey logo

Comments (7)

fivetanley avatar fivetanley commented on May 22, 2024

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.

rwjblue avatar rwjblue commented on May 22, 2024

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.

bcardarella avatar bcardarella commented on May 22, 2024

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.

bcardarella avatar bcardarella commented on May 22, 2024

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.

stefanpenner avatar stefanpenner commented on May 22, 2024

until what @rwjblue lands, that is unfortunately just a reality for now.

from rfcs.

rwjblue avatar rwjblue commented on May 22, 2024

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.

bcardarella avatar bcardarella commented on May 22, 2024

@rwjblue that worked, thank you!

from rfcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.