What would you recommend for a navigation and stat...
# multiplatform
a
What would you recommend for a navigation and state management platform that is not too difficult to learn to use? I'm thinking that Voyager might be one of the easier options, and I wonder if their code examples are a good place to start. If anyone has any example code that they could share, I'd love to see how you're using the library. Also, does this example show the proper structure for an app with Voyager? I'm new to reactive programming, and am starting out working on a pretty small app. Any help is appreciated. 🙂
d
I'd recommend starting out with a
when
control-flow statement for navigation and a
StateFlow
for state management.
e
@Andrew you can try #decompose . It is UI agnostic but works well with compose.
decompose intensifies 1
a
Thanks for the pointers. I think I'll try to learn the Redux pattern, then try to implement it with
when
and
StateFlow
. There was another comment somewhere on Slack pointing to a very simple custom implementation of MVI, but I'll have to look for the link.
e
@Andrew All MVI/Redux architectures are very similar. They differ only in implementation details and usually it is a matter of personal taste. People used to Android MVVM like more visually similar libraries. People used to React/Redux can like other solutions more. If you don’t care about additional things, like logging, time travel, state management you can just do Redux/MVI in a couple of lines of code just with (or even without) any reactive framework (Coroutines, RxJava, Reaktive, etc). But when your project grows and if you are targeting mobile (especially Android, where state management can be more challenging) you may implement all required stuff yourself or just go with one of a ready made solutions. I personally recommend try to do it by yourself first and when you know what do you need choose the library, if necessary. For example #mvikotlin has pretty steep learning curve, but offers a lot of features like logging and time travel. If you don’t need any of that you probably don’t need that level of complexity. The same with navigation. Personally I think that the UI should be secondary and the navigation shouldn’t be part of it. In large mobile apps often it is necessary to be able to save and restore navigation state. Redux/MVI pattern is very handy here. If you divide navigation state from actual navigation in the UI things become very simple. And libraries like #decompose can help to use that approach without boilerplate code. But if you just have a couple of screens any navigation library like Voyager will just work and you can take the simplest one.
đź’Ż 1
👍 1