hmlongco / Factory

A new approach to Container-Based Dependency Injection for Swift and SwiftUI.
MIT License
1.71k stars 107 forks source link

Added section to the readme about "mocking" something inside the singleton scope #97

Closed VladimirAmiorkov closed 1 year ago

VladimirAmiorkov commented 1 year ago

Hi,

Hope that you accept contributions no matter the size of the contribution.

After some research in the new 2.1 API I found a solution to #96 so I decided to contribute and update the readme accordingly.

hmlongco commented 1 year ago

I think most of this is addressed in 2.1.3. Pushing/popping containers has no effect on singletons, their scope is outside that of a single container.

That said, registering a change on a singleton Factory works as it did before, the assumption being that if you registered it you're expecting it to be used.

See the Testing Singletons section in Testing for more.