Swiftpack.co - epiline/SolidDI as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by epiline.
epiline/SolidDI release/1.0.0
Try to create my own DI container
⭐️ 2
🕓 1 year ago
.package(url: "https://github.com/epiline/SolidDI.git", from: "release/1.0.0")

SolidDI

Simple solution for DIC

Dependecy registration

Single dependency


diContainer
    .register(XMLDecodable.self) { _ in
        return XMLDecoder()
    }
    .asSingleton()

Lazy single dependency


diContainer
    .register(ErrorLoggable.self) { _ in
        return LocalErrorLogger()
    }
    .asLazySingleton()

Weak dependency


diContainer
    .register(XMLValidator.self) { _ in
        return XMLValidator()
    }
    .asWeak()

Dependency resolvation

Local DI container


let diContainer = DIContainer()

diContainer
    .register(XMLDecodable.self) { _ in
        return XMLDecoder()
    }
    .asLazySingleton()

let decoder1: XMLDecodable = diContainer.resolve()
// or
@Resolve(container: diContainer) var decoder2: XMLDecodable

Global DI container


GlobalDI
    .container
    .register(XMLDecodable.self) { _ in
        return XMLDecoder()
    }
    .asLazySingleton()

let decoder1: XMLDecodable = GlobalDI.container.resolve()
// or
@Resolve var decoder2: XMLDecodable

Registration/Resolvation graph

Снимок экрана 2022-04-21 в 02 36 09

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies on all platforms.

Снимок экрана 2022-04-21 в 03 06 48

GitHub

link
Stars: 2
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics