square / Cleanse

Lightweight Swift Dependency Injection Framework
Other
1.78k stars 90 forks source link

API Facelift #180

Closed sebastianv1 closed 2 months ago

sebastianv1 commented 2 years ago

The public interface for Cleanse was inspired by Java's Guice and feels a bit outdated and less idiomatic. This has created some friction for other considering using Cleanse as a DI solution. I'd like to facelift the API using some of the modern language features (i.e result builders). Put together a functional POC: https://github.com/sebastianv1/SwiftInjector

static func configure(binder: Binder<Unscoped>) {
     binder.bind(SomeType.self).to { (depA: A) in
         return SomeType(depA: depA)
     }
}

becomes -->

static var binding: some SwiftInjector.Binding {
    Group {
        Bind(SomeType.self) { (depA: DepA)
            SomeType(depA: DepA)
        }
    }
}

Any interest to iterate on the API together @jbeachwood or @chrissonoda ? Would include interop with the old API to support easy migrations.

sebastianv1 commented 2 years ago

(And @brianwang9100 )

brianwang9100 commented 2 months ago

Cleanse is now deprecated. Please read the deprecation notice on the README for next steps. Thank you!