hello everyone, first of all sorry to bother you ...
# mvikotlin
t
hello everyone, first of all sorry to bother you with this rather basic, general MVI question 🙈 i just started my first "MVI project" and try to learn by reading sources from example apps like the todo-app and try to use the frameworks that are used/mentioned there. (thx a lot @Arkadii Ivanov for all your nice work, btw!) but i somehow do not understand how MVI is meant to work... i mean, compose ui needs state change for recompose. but at the same time, time consuming intents/actions should be done off the UI thread. and the new state is returned when the intent is finished, right (circulation/one direction)? so does that mean that the UI won't change (e.g. toggle switch) until the new state was returned from the server/db?
1
a
Hello and thanks for the thanks! Indeed, in declarative UI views reflect the state. So in case of a check box, there usually a flag in the state. When you tap on the check box, it calls the callback. You then send an
Intent
to the
Store
. The
Store
should toggle the flag in the state before starting any async operations.
t
oh. i see, thx. so basically, i only fetch the state once from remote and then i manipulate it myself (and also send manipulations back to remote)? i somehow thought, that i do not need to set the state at all with all the nice frameworks 🤭 i understood it the way that i execute one async task to update remote data and after that, the reaktive framework, which oberves the remote data (with another async task), will automatically provide the new state to the ui.
a
If I understand your question correctly, the client always contains and manipulates its state locally. This is regardless of the architecture/frameworks/patters/etc. Usually apps manipulate its local state. Communication with backend is done asynchronously. An example of flow could be: 1. The user clicks a button 2. The client disables the button and shows a loader (e.g. by change its local state) 3. The client executes async request to the server 4. Once a response is received, the client enables the button and either shows an error or proceeds with the flow
👍 1
t
yes, you understood my question right. i was confused about how state is updated when i introduce new patterns/frameworks. thanks again for your quick response and keep up the good work!
K 1