https://kotlinlang.org logo
Title
n

Nikiizvorski

03/17/2021, 4:36 PM
Hi i was wondering which project would you recommend at this stage if we want the most clean way of MVI. Would you recommend MVIKotlin or MVICore both to me looks great and the implementation feels good. I still want to do my own implementation over it. But a little confused which one is looking better at this stage to me. In a way i prefer the MVIKotlin more. To me both look very very good. I am asking from the point that soon i will be starting a new project that might turn out to be a multi platform one and there will be new people that i might need to introduce the MVI implementation. I would like them to be able to grasp it quicker and was curious for your input. Thank you
a

Arkadii Ivanov

03/17/2021, 11:04 PM
HI. Both libraries provide similar API for writing Stores (Features in MVICore). However there are some key differences: • In MVICore it is not possible to read the current (updated) state from inside the Feature. So if you need to check the new state after it is changed, you have to use
PostProcessor
. This gives MVICore some additional purity, which might be improve maintainability. In MVIKotlin you have
getState: () -> State
supplier that always returns the current state. This reduces boiler plate code, sometimes significantly, and so there is no
PostProcessor
required. • In MVICore if you want to publish some News (aka side effects), you have to use
NewsPublisher
. This again due to that purity. In MVIKotlin you can publish Labels (same thing as News in MVICore) directly from
Executor
, and so no
NewsPublisher
is required. Again purity vs boiler plate code. • MVICore is developed and heavily used by Badoo/Bumble, which is quite a big company. So it is proved to work well. MVIKotlin is developed by me in my spare time, however there are known users/companies as well. • If you are planning to use Kotlin Multipaltform, then at the moment you can't use MVICore in common code, because it depends on RxJava2. MVIKotlin is multiplatform library, and supports Reaktive and Coroutines. • The way how you create Stores/Features is also different. In MVICore you are encouraged to extend
BaseFeature
class or one of its descendants, and pass components to super. In MVIKotlin you usually use
StoreFactory
interface where you pass components, and it creates an implementation for you. • Both libraries provide logging and time travel functionality. However the way how it is implemented is different. MVICore has global middleware registry, and logging and time travel are middlewares provided by the library. In MVIKotlin there are different Store implementations, and so different Bot libraries have logging and time travel functionality. However their implementation is also different. In MVICore there are middlewares, logging and time travel are middlewares. There is a global middleware registry, which is used by the library internally. In MVIKotlin there are separate Store implementation for logging and time travel, and so separate store factories. You can combine factories or even implement your own Store implementations. • There is also such a thing as
binder
in both libraries. In both libraries it makes lifecycle-aware connections between inputs with outputs. However in MVICore the
binder
also has responsibility to wrap consumers into middlewares from the global registry.
👍 2
n

Nikiizvorski

03/18/2021, 8:22 AM
Thanks you @Arkadii Ivanov Very very helpful and exactly what i was looking for.
👍 1