I've got more of an MVI-generic question since I'm...
# mvikotlin
a
I've got more of an MVI-generic question since I'm very new to this architecture. My screen has a text input that a user can submit, like a chat app. The submission may go well; in that case, the input field gets cleared to prepare for the following input. The input should stay in the field if something goes wrong (e.g., a network error). That means the view part must somehow distinguish whether the submission went well or failed. I can think of a few ways to achieve that: One way is to propagate the input all the way via the state, and manage it via the executor. But the problem is that the business logic is now aware of the UI component-specific requirement. Another way could be solving that with labels, i.e., subscribing the component to the "all went well" label. But perhaps there's some fundamentally better practice for this class of problem. Would appreciate any thoughts! :)
a
From my point of view, the input text should be part of the state. The store should be responsible for any validations and posting the input to the backend. You can have an
isLoading
flag in your state, indicating that the input is being processed. You can also add something like
inputError
property in your state, so that you can display the error in the UI (e.g. as a red label under the text field).
a
Thanks, that helps! Rereading the documentation and the examples, I realized that my understanding of the roles of Views and Stores was quite a bit off.