Function ConcatInjectable

  • Create an Injectable factory function without dependencies (i.e. the factory function has no arguments) that appends a Service onto an existing array of Services of the same type.

    Ex:

    import { myServiceFactory, MyService } from './my-service'

    const createMyService = ConcatInjectable(
    myServiceFactory.token,
    (): MyService => { return ... },
    )

    // Consumers then do:
    const myConsumingServiceFactory = Injectable(
    'myConsumingService',
    [myServiceFactory.token] as const,
    (myServices: MyService[]) => { return ... }
    )

    Type Parameters

    • Token extends string

    • Service

    Parameters

    • token: Token

      A string Token identifying an existing Service that has an Array type, to which will be appended the Service created by this factory function.

    • fn: (() => Service)

      A function with no arguments which returns the Service.

    Returns InjectableFunction<{
        [T in keyof Token]: Service[]
    }, [], Token, Service[]>

  • Create an Injectable factory function with dependencies (i.e. the factory function has arguments) that appends a Service onto an existing array of Services of the same type.

    Ex:

    import { myServiceFactory, MyService } from './my-service'

    const createMyService = ConcatInjectable(
    myServiceFactory.token,
    ['DependencyA', 'DependencyB'] as const,
    (a: A, b: B): MyService => { return ... },
    )

    // Consumers then do:
    const myConsumingServiceFactory = Injectable(
    'myConsumingService',
    [myServiceFactory.token] as const,
    (myServices: MyService[]) => { return ... }
    )

    Type Parameters

    • Token extends string

    • Tokens extends readonly string[]

    • Params extends readonly any[]

    • Service

    Parameters

    • token: Token

      A string Token identifying an existing Service that has an Array type, to which will be appended the Service created by this factory function.

    • dependencies: Tokens

      A readonly list of Tokens corresponding to dependencies (i.e. arguments to the Factory), which will be resolved by the Container to which this Injectable is provided.

    • fn: ((...args) => Service)

      A function with no arguments which returns the Service.

    Returns InjectableFunction<ServicesFromTokenizedParams<Tokens, Params>, Tokens, Token, Service[]>

Generated using TypeDoc