Closed hyazel closed 1 year ago
See the section "The Factory Wins" in the documentation on Factory Modifiers.
https://hmlongco.github.io/Factory/documentation/factory/modifiers
Thanks !
It seems that using once()
modifier would solve what I want to achieve.
Is there a danger or a side effect I don't see, using the once()
modifier on all my services (which are not singleton
like the example in the once()
documentation) for my previews ?
Once just adds a small bit of processing to the resolution process, so you can use it as much as you like. That said, I'd only use it for scenarios where you're trying to override one of the contexts and you put those context modifiers inside of the Factory. It makes no sense to have it for plain or scoped factories.
Don't forget the auto registering option.
Hello,
I register a
service
like this :My purpose is to have a
CollectionServiceMock
for previews that usecollectionMock1
in most of my views.But sometimes I'd like to use an another mock than
collectionMock1
.In my preview I tried to do something like this :
But doesn't seem to use the
collectionMock2
instead of thecollectionMock1
.My question is : How do you switch your mock during previews ?