We defined a model interface, and we now need to implement it. We'll cover the essential concepts behind Model stores. A model store is a thread-safe way of managing state in an MVI application. It's a concept borrowed from state container libraries like Flux and Redux. Let's see how to use RxJava to build a ModelState Store
Small apology, I'll be lazy, and basically quote the lib's sales pitch:
Basically: A Subject except without the ability to call onComplete or onError.
Subjects are useful to bridge the gap between non-Rx APIs. However, they are stateful in a damaging way: when they receive an onComplete or onError they no longer become usable for moving data. This is the observable contract and sometimes it is the desired behavior. Most times it is not.
Relays are simply Subjects without the aforementioned property. They allow you to bridge non-Rx APIs into Rx easily, and without the worry of accidentally triggering a terminal state.
We're really in a situation where
Relays make the most sense. Our
intents relays are private to our model store, and thus can't error out, or complete. That said,
Subjects do still make sense in other situations.