Skip to content

Add support for dependency scopes #2

@tlaanemaa

Description

@tlaanemaa

To enable more complex dependency injection schemes, we need to start supporting dependency scopes.

Constraints:

  • We should support the following scopes

    • Transient
    • Singleton
    • Request
  • The scope declaration API should look like this

container.bind<IMyComponent>(MY_COMPONENT, myComponent, { scope: 'transient' }
  • Default scope should be transient

  • All scopes should be exported from the package as a read only collection

import { scope } from 'tinioc'

container.bind<IMyComponent>(MY_COMPONENT, myComponent, { scope: scope.TRANSIENT }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions