Function diDep

  • Extract value from Dependency Injection by unique string literal

    Should be called within diInit callback

    Type Parameters

    • T

    Parameters

    • dep: string

    Returns T

    type User = {
    login: string;
    roles: string[];
    }
    const user: User = {login: 'root', roles: ['admin']}
    diSet('user', user)
    diDep<User>('user') // {login: 'root', roles: ['admin']}

    DiNotInitializedError if called outside of diInit callback

    DependencyNotRegisteredError if dependency not registered

  • Extract overriden function from Dependency Injection

    Should be called within diInit callback

    Type Parameters

    • T extends Function

    Parameters

    • dep: T

    Returns T

    const fun = () => 1
    diSet(fun, () => 2)
    diDep(fun)() // 2

    DiNotInitializedError if called outside of diInit callback