Swiftpack.co - devxoul/SwinjectSafeAuto as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by devxoul.
devxoul/SwinjectSafeAuto 1.0.1
SwinjectSafeAuto allows to auto-register services to the container and verify the required services are properly registered.
⭐️ 14
🕓 1 year ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/devxoul/SwinjectSafeAuto.git", from: "1.0.1")

SwinjectSafeAuto

SwinjectSafeAuto allows to auto-register services to the container and verify the required services are properly registered.

This project is inspired by SwinjectAutoregistration.

Features

  • Auto-register services to the container.
  • Verify that required services are properly registered to the container.

Usage

container.autoregister(NetworkingProtocol.self, initializer: Networking.init)
container.autoregister(MyServiceProtocol.self, initializer: MyService.init)

// This method will throw an error in DEBUG build when the required services are not properly reigstered.
try! container.verify()

// You can safely resolve services after verification.
container.resolve(MyServiceProtocol.self)

Limitation

  • SwinjectSafeAuto cannot verify manually-registered services using container.register().
  • SwinjectSafeAuto cannot be used with SwinjectAutoregistration in the same project.

License

SwinjectSafeAuto is under MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 14
Last commit: 1 year ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 year ago
  • Fix a potential thread safety issue (cf7809d059e410a443a0ce968effa34d3bd7469f)

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