Cleanse icon indicating copy to clipboard operation
Cleanse copied to clipboard

API Facelift

Open sebastianv1 opened this issue 2 years ago • 1 comments

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 avatar Jul 02 '22 17:07 sebastianv1

(And @brianwang9100 )

sebastianv1 avatar Jul 02 '22 17:07 sebastianv1