-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MvRxStateStore based on kotlin coroutines #79
Comments
@ATizik Do you have a |
@gpeal |
@ATizik Would love to see a PR. If you have a good way to benchmark it, that would be great too! |
I still do not understand Why can't simply use the Main Thread to avoid race conditions of setting the state? The |
@luozejiaqun |
First question, if there is nothing specific about main thread, why don't use the main thread. Since every |
@luozejiaqun A fundamental principle of MvRx is that you observe a stream of immutable state. Storing a SparseArray in LiveData actually enables you to write buggy code. If you modify an element in the array, your LiveData won't update. That's why MvRx enforces immutability. Regarding the background thread, there are performance advantages in keeping it off the main thread but we have implemented it in such a way that there should be no cognitive overhead for the developer. Why not offload things off the main thread if we can? |
@gpeal I know MvRx enforces immutability, because of the reason, I can't use SparseArray in the State. The MvRx's suggestion is using immutable list, but I don't think that makes sense. Because of performance advantages we use SparseArray, immutable list can't meet that requirements. LiveData maybe buggy, but that's my only choice for now. Regarding the background thread, I know the performance advantages.But using the main thread and no more new threads also has performance advantages. |
@luozejiaqun Let's separate that discussion from the coroutines state store |
This PR converts the internal implementation from RxJava to Coroutines. This was not designed to be a breaking change so no external APIs still use Disposable. However, a new API was added: ViewModel.stateFlow This property allows consumers to easily combine MvRx state with other operations or chain it to other Flow operators. Thoughts on this API? It doesn't violate the primary concern of providing synchronous state access from within a ViewModel. Once this is landed, I think it is time to create the mvrx-rxjava2 artifact and start splitting off RxJava for good. Thoughts? Fixes #296 Fixes #79 #130
This PR converts the internal implementation from RxJava to Coroutines. This was not designed to be a breaking change so no external APIs still use Disposable. However, a new API was added: ViewModel.stateFlow This property allows consumers to easily combine MvRx state with other operations or chain it to other Flow operators. Thoughts on this API? It doesn't violate the primary concern of providing synchronous state access from within a ViewModel. Once this is landed, I think it is time to create the mvrx-rxjava2 artifact and start splitting off RxJava for good. Thoughts? Fixes #296 Fixes #79
Since MvRxStateStore can be a performance bottleneck on screens with state changing very frequently, maybe it would be beneficial to implement it with coroutines instead of Rx?
I can provide performance comparisons to determine actual performance gain in case it's needed
The text was updated successfully, but these errors were encountered: