A new approach to Container-Based Dependency Injection for Swift and SwiftUI. Factory is strongly influenced by SwiftUI, and in my opinion is highly suited for use in that environment. Most container-based dependency injection systems require you to define in some way that a given service type is available for injection and many require some sort of factory or mechanism that will provide a new instance of the service when needed. Unlike Resolver which often requires defining a plethora of nested registration functions, or SwiftUI, where defining a new environment variable requires creating a new EnvironmentKey and adding additional getters and setters, here we simply add a new Factory computed variable to the default container. When it's called our Factory is created, its closure is evaluated, and we get an instance of our dependency when we need it.

Features

  • Factory doesn't tie you down to a single dependency injection strategy or technique
  • Factory supports containers, scopes, passed parameters, contexts, decorators, unit tests, SwiftUI Previews, and much, much more
  • Little to no setup time is needed for the vast majority of your services, resolutions are extremely fast, and no compile-time scripts or build phases are needed
  • Factory is compile-time safe; a factory for a given type must exist or the code simply will not compile
  • Defining a registration usually takes just a single line of code. Same for resolution
  • Factory is free and open source under the MIT License

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow Factory

Factory Web Site

You Might Also Like
Gain insights and build data-powered applications Icon
Gain insights and build data-powered applications

Your unified business intelligence platform. Self-service. Governed. Embedded.

Chat with your business data with Looker. More than just a modern business intelligence platform, you can turn to Looker for self-service or governed BI, build your own custom applications with trusted metrics, or even bring Looker modeling to your existing BI environment.
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Factory!

Additional Project Details

Operating Systems

Apple iPhone

Programming Language

Swift

Related Categories

Swift Container Management Software

Registered

2023-07-03