Closed littleGnAl closed 6 years ago
Hi
I think that all the info required inside your createHeader
, createHeaderTitle
could be fetched inside the logic, and be included into the logic's Result
, so the reducer wouldn't have to hit the network or database, but only compute data.
I know that having access to the state from inside the logics is something important that I didn't address yet. I'm not sure I'll take the time to do that soon. You can check libraries like RxRedux that seems to allow that easily.
@oldergod Thank you for your reply. For 1, but if I need to create adapter items based on the previous state, this solution will not work, such if the previous adapter items are empty, I should also add a header for it, you can check this: https://github.com/littleGnAl/Accounting/blob/591a8705bffebc79690f8bb716b35f81dc8d183c/app/src/main/java/com/littlegnal/accounting/ui/main/MainActionProcessorHolder.kt#L332
Everything could be done inside a logic I think. You can still compose your stream after you've got a success object : multiple operators are no problem.
Ok, thank you, I will think more about it.
Hello, @oldergod thank you for the amazing MVI implementation. I have been using it for a while in my project. I like this implementation very much, but I have encountered some problems, although they have been solved, I have been confused to do so, is it right or not.
I am trying to write an accounting app for your implementation. I need to display a list of all accountings on the home page. I need to add a section header before the accounting of the day. The section header needs to be displayed the sum of the day's accountings because the list needs to be paged after paging, I don't know that the last accounting adapter item displayed is the last data of the day, so the sum can only be obtained from the database through SQL:
You can check out my implementation here https://github.com/littleGnAl/Accounting/blob/591a8705bffebc79690f8bb716b35f81dc8d183c/app/src/main/java/com/littlegnal/accounting/ui/main/MainActionProcessorHolder.kt#L77. My solution is to put the
observeOn()
method behindscan()
and let the reducer switch to the main thread after it has finished executing.There is a page that requires the user to select some and fill in some information, such as username, email, address, etc. The definition of ViewState is as follows:
When the user clicks the confirmation button, it checks whether the information is valid. It will be saved the to the server if it is valid. I tried to save this information in
ViewState
, but I can only check if the information ofpreViewState
is valid in thereducer
. But in the reducer cannot call the Retrofit API to save the data, my current solution is to put these user information into theUserInfoValueHolder
, and then in the correspondingprocessor
to check whether the value ofUserInfoValueHolder
is valid, if valid directly call The API saves the user information to the server:class UserInfoActionProcessorHolder { private var userInfoValueHolder: UserInfoValueHolder? = null
}