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

Other Useful Business Software
Go from Data Warehouse to Data and AI platform with BigQuery Icon
Go from Data Warehouse to Data and AI platform with BigQuery

Build, train, and run ML models with simple SQL. Automate data prep, analysis, and predictions with built-in AI assistance from Gemini.

BigQuery is more than a data warehouse—it's an autonomous data-to-AI platform. Use familiar SQL to train ML models, run time-series forecasts, and generate AI-powered insights with native Gemini integration. Built-in agents handle data engineering and data science workflows automatically. Get $300 in free credit, query 1 TB, and store 10 GB free monthly.
Try BigQuery Free
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