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

Orange.Modularity.inject should have ability to optional register resolved instance #31

Open
jonatannyberg opened this issue Feb 23, 2016 · 1 comment

Comments

@jonatannyberg
Copy link
Contributor

It would be useful to tell the Orange.Modularity.inject decorator to register an instance of a specific type if it has not already been registered in the container.

Something like this maybe: (if possible)

@Orange.Modularity.inject({
    register: [ FooBar ]
})
class Foo {
    constructor(bar: Bar, fobar: FooBar) { }
}
@markusjohnsson
Copy link
Contributor

It seams weird to me that Foo should control the lifetime of FooBar. That should be up to either a all-knowing module or to FooBar itself.

I'd rather have:

// causes FooBar to register as singleton the first time it is resolved.
@Orange.Modularity.singleton 
class FooBar 
{
}

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