Closed mradzinski closed 3 years ago
Hey!
One time I had to set up a scenario where there was a global module with all the keys in it, but I'd say that's actually trickier because it requires map multibinding (the key and the fragment type live in separate modules, and the navigation
modules with the keys would not actually see the fragment types), very similar to this experiment.
If the key is next to the fragment, then it's actually fairly straightforward, it's the same approach as outlined here ("theoretical correct solution") namely that the module would expose an interface that is handled by a common parent (probably :app
) with an implementation that is provided to the child module by DI.
retrieve the actual DefaultFragmentKey implementation
I don't think you need to expose the keys, what you need to expose is the intention to cross module boundaries via an action. 🤔
I kind of agree on the "theoretical correct solution", though I find it to be a bit crippling. If you wanna provide a constructor to the key (to build a Fragment, for example), an interface will not be able to implement such constructor. So I guess most of the times you'll end up either with an abstract class, or some other kind of implementation
Actually, any argument that needs to be passed to the key can be an argument of the method in the interface. So constructor parameters (and therefore bundle arguments for the fragment) are still possible in a typesafe way.
Did that answer your question?
Indeed @Zhuinden. Let's close this issue. Thanks for your help and feedback.
Hey Gabor! How's it going? I was wondering how easily achievable it is to have simple-stack manage the navigation between screens on a multi-module project where
DefaultFragmentKey
have to be stored per module/feature. How would one access such keys without creating intertwined module dependencies?I guess we could create some globally available interfaces and relay on DI to retrieve the actual
DefaultFragmentKey
implementation, but it would be great to know if you already had to solve this scenario and how did you solve it.Thanks!