square / Cleanse

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

Scope Singleton #96

Closed TomVanDerSpek closed 5 years ago

TomVanDerSpek commented 5 years ago

According to the readme on GitHub I should be able to scope a Binder as :

// Required function from Cleanse.RootComponent protocol.
static func configure(binder: Binder<Unscoped>) { }

Line 17 in Scope.swift also states the following: /// Currently there are only two scopes,UnscopedandSingleton.

But it looks like Singleton is completely removed from the project. Can you update the documentation and let me know what I should use instead?

sebastianv1 commented 5 years ago

I think adding the Singleton scope into the project by default would be a good idea. Originally it was excluded as scopes are user created (and we recommend calling the scope at the root component Singleton), but you're right, that isn't very clear in the README.

I'll open a PR for this, but if you'd like to create one for now, simply put in your project struct Singleton : Cleanse.Scope {} and you should be good to go.