Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InjectionMapping

Injector data mapping instance.

author

Jānis Radiņš

Hierarchy

  • InjectionMapping

Index

Constructors

constructor

  • Create new instance of injector mapping

    Parameters

    • type: Type<any>

      Mapping type of injected value by which it will be requested from injector

    • injector: Injector

      Hosting Injector instance of current mapping

    • masterSealKey: Object

      Master seal key is necessary for unsealed by injector during destroy

    Returns InjectionMapping

Properties

injector

injector: Injector

Hosting Injector instance of current mapping

type

type: Type<any>

Mapping type of injected value by which it will be requested from injector

Accessors

destroyed

  • get destroyed(): boolean

sealed

  • get sealed(): boolean

Methods

asSingleton

  • asSingleton(): this
  • Makes the mapping return a lazily constructed singleton instance of the mapped type, for each consecutive request.

    Returns this

    The InjectionMapping the method is invoked on

destroy

  • destroy(): void | Error

getInjectedValue

  • getInjectedValue(): any

seal

  • seal(): Object
  • Seal mapping and don't allow any changes to it whist Injector that hosts this mapping is destroyed or mapping is unsealed.

    Returns Object

    Seal key to be used for unseal operation.

toExisting

  • toExisting(type: Type<any>): this
  • Makes the mapping return existing mapping from current injector or any of its parents upon each request

    Parameters

    • type: Type<any>

      Exsting mapping type to use as for a return value.

    Returns this

    The InjectionMapping the method is invoked on

toSingleton

  • toSingleton(type: Type<any>): this
  • Makes the mapping return a lazily constructed singleton instance of the mapped type for each consecutive request.

    Parameters

    • type: Type<any>

      Type that should be used as source of singleton instance

    Returns this

    The InjectionMapping the method is invoked on

toType

  • toType(type: Type<any>): this
  • Makes the mapping return a newly created instance of the given type for each consecutive request.

    Parameters

    • type: Type<any>

      Type that should be used as new injected value is spawned

    Returns this

    The InjectionMapping the method is invoked on

toValue

  • toValue(value: any): this
  • Makes the mapping return the given value for each consecutive request.

    Parameters

    • value: any

      Hard coded value to be returned for each request

    Returns this

    The InjectionMapping the method is invoked on

unseal

  • unseal(key: Object): this
  • Unseal mapping.

    Parameters

    • key: Object

      Seal key which was returned as a return value for seal() operation.

    Returns this

    The InjectionMapping the method is invoked on