https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
g

Guilherme Delgado

08/11/2021, 9:27 PM
Hello! I stumbled upon Orbit-MVI and I’m very motivated to try it out. Do you think we can also benefit from using it with a StateMachine - let’s say in the reduce function - so we can have a better control over the State? Have you tried?
m

Mikolaj Leszczynski

08/12/2021, 5:38 AM
You can already use sealed classes for more fine-grained states within your
ContainerHost
. Could you please explain how you think this library would improve things beyond making state transitions more strict (possibly something you can achieve manually as well)? Overall the topic of state machines is something we know can work with Orbit but we haven’t explored it in a lot of detail yet - we want to do a deep dive into it at some point. Maybe there’s a simple API we could add to improve working with state machines - e.g. adding declarative transitions
g

Guilherme Delgado

08/12/2021, 8:33 AM
For now I’m starting to migrate my MVVM to MVVM+ 🙂 I was just thinking ahead and shared some thoughts that came into my mind. Sealed classes help for sure, but the state machine avoids messy transitions, in other words, the transitions are coupled to the FSM. I can’t go from A to C if the FSM says I have to be in B to go to C. Maybe I’m overthinking 😅
m

Mikolaj Leszczynski

08/12/2021, 8:36 AM
these are all nice ideas for sure - and we will definitely explore them. MVI/Redux does not really require you use an FSM so I suggest going simple first 🙂 If you feel like you need it you can always add it.
👍 2
g

Guilherme Delgado

08/12/2021, 8:37 AM
yes, that’s my idea, first update to MVVM+, and then iterate if necessary 😊
o

Oleksii Malovanyi

08/12/2021, 9:01 AM
BTW, could a sealed class be another sealed class? If so, it solves the state-to-state routing on compilation level
Copy code
sealed class A {
    sealed class B : A() {
        class C : B()
    }
}

val c = A.B.C()
IMHO it looks quite bad 😆
🙈 2
g

Guilherme Delgado

08/12/2021, 9:03 AM
yup, that code is valid 😅
o

Oleksii Malovanyi

08/12/2021, 9:05 AM
in my experience so far state as a sealed class would require quite additional sugar, so I prefer resolve this rails by state properties (which in turn could be enum or sealed class or ….)
m

Mikolaj Leszczynski

08/12/2021, 10:32 AM
could also define possible state transitions as e.g. extension methods on a hierarchy of flat sealed classes… But I agree, this topic needs a deep dive and extra work to be nice to use
5 Views