forXifLess / LinkNavigator

🌊 Easy & Powerful navigation library in SwiftUI
Other
332 stars 24 forks source link

Is there any library-supported way to scope store when integrating with TCA? #7

Closed jay-handhug closed 1 year ago

jay-handhug commented 1 year ago

Hello there. I like you guys way to solve SwiftUI's poor navigating system and i'm thinking i use it in my project someday soon.

In TCA, one of the common patterns is scoping a store that have child store so that they can be related as parent-child relation. So, suppose that there's two View-A, B and B is navigated by A. And i want store B is child of store A. But it seems like there's no library-supported way to scope store A when creating View B in RouteBuilder. So, i'm just wondering if you guys have any solution of like this situation.

Thanks in advance.

interactord commented 1 year ago

@jay-handhug Thank you so much for sharing your thoughts and values.

jaeho-flitto commented 1 year ago

Thank you for your visit. @jay-handhug πŸ˜„

The key concept of LinkNavigator is to ensure independency for each View and to allow developers to add/delete views easier.

As you said, when you navigate from A to B, you can inject some values with items parameter. However, this injection through RouteBuilder ​​only happens once, when the view is created. A and B Views are not subscribing to each other's value changes for the sake of independency.

In summary, my team has two rules for combining TCA with LinkNavigator.

I hope this helps. If you got some suggestions, please leave more comments!

jay-handhug commented 1 year ago

Thanks for your replying.

It could be one solution that you don't relate two views when navigating as you said. But in my case, it makes more sense that they have a relation, so i came up with several options and one could be to have a reference to the store that you want to scope, and you can access it later to scope it when you implement RouteBuilder. But i think it can easily make mistake especially when you have many same Views in your view hierarchy so they have same kind of Store class like the situation where views are recursively navigated. I think i can make it more progress with this way keeping researching.

Thanks anyway, and if there's anyone who is interested in integrating the library with TCA like this way, feel free to ask me some tips to make it more ergonomic way.

farhanadji commented 1 year ago

Hi @jay-handhug I also facing the same issue on my project where I have a lot of child navigation which have a dependency for its parent. If you don't mind, could you please share the way you solve this issue? Thank you

interactord commented 1 year ago

We are currently working on a workaround on how to use RouteBuilder dynamically so it can be reused.

Ideas and PR are always welcome.