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

Proposal: Track instance registrations separate from factory registrations #21

Open
dgeb opened this issue Feb 10, 2017 · 1 comment
Open

Comments

@dgeb
Copy link
Member

dgeb commented Feb 10, 2017

In a Registry, both factories and instances can be registered via register, unregistered via unregister, and accessed via registration.

@krisselden and I discussed the benefits of separating the interfaces to register factories and instances. This change will provide stronger typing for storing and accessing factories and instances.

This would entail the following changes:

  • Change Registry#register to accept a more strongly typed FactoryDefinition<any>
  • Introduce the following methods to Registry:
    • registerInstance(specifier: string, instance: any): void
    • unregisterInstance(specifier: string): void
    • registeredInstance(specifier: string): any
  • In Container#lookup, check the registry's registeredInstance as a first step and return an instance if found.
@dgeb
Copy link
Member Author

dgeb commented Feb 11, 2017

I just tweaked the description of this issue, which originally mentioned a simplification for registration options. However, I realized that this was an oversimplification since we still need to register options (like singleton: false) by type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant