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
Our Free Plans just got better! | Auth0 by Okta Icon
Our Free Plans just got better! | Auth0 by Okta

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your secuirty. Auth0 now, thank yourself later.
Try free now
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