Open Suri1044 opened 6 months ago
Thank you,
Will continue investigating this.
Hi Eric, One question I have, How to use a common view in multiple tabs since the view has the router instance, needed for push and pop and we need to initialise all the router instance?I have a case which has tabs and a common view need to trigger from all below tabs. Appreciate your quick response Regards,SureshOn 15-Feb-2024, at 7:26 PM, Eric Palma @.***> wrote: Thank you, Will continue investigating this.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Hi,
Apologies for the late response. I will look at the issue over the weekend and get back.
Hello @Suri1044 ,
Unfortunately the Routing
library does not support this use case out of the box. Currently views need to specify which Router
type they use for the compiler.
The only work around I can think of is declaring two optional router properties in the view, so something like:
struct SharedView: View {
@StateObject var routerA: Router<ExampleA>?
@StateObject var routerB: Router<ExampleB>?
init(routerA: Router<ExampleA>?, routerB: Router<ExampleB>?) {
_routerA = StateObject(wrappedValue: routerA)
_routerB = StateObject(wrappedValue: routerB)
}
var body: {
...
}
}
You would have to add your own logic to ensure only one router instance is used in the view at any given time, depending on where it was created from. This is not the cleanest code but it should work.
Hope that helps.
@obvios Thanks for the info. Any update on the memory issue ?
No update, have not found root cause yet.
@obvios: Hi Just checking out any updates on the above. And also Can we enhancement for deeplinks? I believe currently deeplinking is not there right and also popToParticular view also we can enhance. Just suggestions
@Suri1044 @obvios It's not a memory leak in the Library, it's something in NavigationStack
.
I made a small demo to show the issue, please take a look at the code. NavigationStackLeak.zip
https://github.com/obvios/Routing/assets/1476754/343a66cb-71aa-42ad-9297-f107b92506f2
I found an article talking about the solution for this issue. https://yeonduing.tistory.com/47
@obvios Hi Eric, For Tracking Purpose i created a new issue and attaching the sample and the video for reference.
I played the app in switching the tabs and also inside tab navigation, the memory is getting increased when i go over and over in the same screens (Attached video),
Also when i logged out, by making the login view as rootview, memory is not releasing at all and still there, Can you please have a look on this issue (Attached code as well) and let me know how to release it.
TabViewLatest.zip
https://github.com/obvios/Routing/assets/68360396/afafd855-3cfa-44d4-a3d0-2b6f9dd86279