You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases when resolving objects graph we want different consumers of the same service to have a reference to the same instance of that service instead of having unique instances. Then shared components scope makes more sense as a default value.
The text was updated successfully, but these errors were encountered:
@ilyapuchka I'm curious as why this is the default scope returned. Feels like this opt-ins to implicit state which can be difficult to reason with when there are issues with the state of those instances. I could also make arguments to where UTs could become flaky or difficult to also reason with.
This is purely a thought exercise, just curious if you had an experiences with this occurring.
It seems to me that this is the most common scope, it's rear when you really need unique objects in the graph or those objects have only single reference so there is no difference between shared and unique scopes for them.
Maybe I'm misunderstanding it let me try and clarify my own mental model of it...
Say you have navigation stack where you have VC's A, B
VC A gets an instance of type Foo and sets a field in it to "Bar"
VC B gets pushed on the stack and grabs an instance of Foo as well.
Given both these instances of Foo are injected/resolved through Dip used the default/shared scope.
Could we expect VC B's instance of Foo have this field set to Bar at this point as well?
In most cases when resolving objects graph we want different consumers of the same service to have a reference to the same instance of that service instead of having unique instances. Then shared components scope makes more sense as a default value.
The text was updated successfully, but these errors were encountered: