Functions

The following functions are available globally.

  • Short syntax for get object by tag Using:

    let object: YourType = by(tag: YourTag.self, on: *container)
    

    also can using in injection or init:

    .injection{ $0 = by(tag: YourTag.self, on: $1) }
    

    Declaration

    Swift

    public func by<Tag,T>(tag: Tag.Type, on obj: DIByTag<Tag,T>) -> T

    Parameters

    tag

    a tag

    obj

    resolving object

    Return Value

    resolved object

  • Short syntax for get many objects Using:

    let objects: [YourType] = many(*container)
    

    also can using in injection or init:

    .injection{ $0 = many($1) }
    

    Declaration

    Swift

    public func many<T>(_ obj: DIMany<T>) -> [T]

    Parameters

    obj

    resolving objects

    Return Value

    resolved objects

  • Short syntax for resolve. Using:

    let yourObj: YourClass = *container
    
    See more

    Declaration

    Swift

    public prefix func *<T>(container: DIContainer) -> T

    Parameters

    container

    A container.

    Return Value

    Created object.