https://kotlinlang.org logo
v

Vishnu Ravi

01/12/2023, 4:10 AM
Happy new year folks, a quick question regarding redux pattern... 🤫 🤔 Is it possible to 'connect' a single store with orbit and let a few view-models update this on certain intents/actions? Appreciate your thoughts and/or references 😅
For example, consider a simple retail app with a list, detail and a cart page. Having a single source of truth in this case would help share/sync a lot of items resulting in a pretty "reactive" app 🤞
m

Mikolaj Leszczynski

01/12/2023, 9:39 AM
Yes of course, Orbit is independent of any UI or platform components. Basically, you can keep a properly scoped
ContainerHost
(not extending
ViewModel
) somewhere in your dependency graph
So you can definitely go for a redux-like global state approach if you wish
yeah, exactly!
v

Vishnu Ravi

01/23/2023, 5:34 PM
Thank you, I was able to come up with a working sample (Please see the attached post) I've 2 questions here 🙏 1. Is this a good approach, using
combine
to derive a ui state, and are we looking at any red flags here? 2. If I write UI tests, can I mock orbit based containers just like any other dependencies or is there a different/better way to simulate states/sideffects (something similar to the approaches mentioned in the official docs here)
12 Views