Replies: 2 comments
-
This can work, but you need to "bake in" the ability to create and destroy the dependency within your own code. @Dependency(\.locationManager) var locationManager
locationManager.create() where static var liveValue: Self {
let locationManager = LockIsolated<LiveLocationManager>(.noOp)
return Self(
create: {
locationManager.withValue { manager in
manager = .live
}
},
destroy: {
locationManager.withValue { manager in
manager = .noOp
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for the advice. I will implement this in our project and let you know - about a week or so from now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I created a dependency called
LocationManager
by following the documentation in this library. It works great - no problems there. However, I would like to scope this dependency to a part of the navigation graph so that when I go back to a place where I don't need the said location manager anymore, i would like to release it from memory. I looked around but I couldn't find a way to configure the dependency this way. If there is already one and I missed that, apologies in advance. I took a snapshot of my memory graph where I would like no longer seeLocationManager
. However, CachedValues object still retains a reference to this dependency. Is this feasible? Check out the following screenshot.Beta Was this translation helpful? Give feedback.
All reactions