Skip to content
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

Auto factory #87

Closed
ktutnik opened this issue Feb 26, 2016 · 2 comments
Closed

Auto factory #87

ktutnik opened this issue Feb 26, 2016 · 2 comments

Comments

@ktutnik
Copy link
Member

ktutnik commented Feb 26, 2016

Sometime a class need to create instance of other class on the fly instead of on creation time. So need to provide a convenient way to do that, without letting user to construct their own factory and reference container on the class.

example

class Factory {
    resolve<T>(key:string){}
}

class MyClass{

}

@Inject("Factory")
class OtherClass{
    factory: Factory;
    constructor(factory: Factory){
        this.factory = factory;
    }

    myMethod(){
        var myclass = this.factory.resolve<MyClass>("MyClass");
    }
}

kernel.bind(new TypeBinding<Factory>("MyClass", MyClass));
kernel.bind(new AutoFactoryBinding<Factory>("Factory", Factory));

this feature require interception feature ready

@remojansen
Copy link
Member

👍 We need to do some thinking about it but sound like a good idea to me.

@remojansen
Copy link
Member

This is done by #102

@remojansen remojansen mentioned this issue Mar 10, 2016
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants