MvRx v2.0.0 Release Notes

  • ๐Ÿ“š Mavericks 2.0 is a ground up rewrite for coroutines. Check out the documentation for 2.0 to find out what is new and how to upgrade.

    ๐Ÿ’ฅ Breaking Changes

    • All mvrx artifact names are now mavericks.
    • If you are using RxJava, you will need to use mavericks-rxjava2 to maintain backwards compatibility. New Mavericks users who just use coroutines can just use mavericks.
    • If your MavericksView/Fragment does not use any ViewModels, invalidate() will NOT be called in onStart(). In MvRx 1.x, invalidate would be called even if MvRx was not used at all. If you would like to maintain the original behavior, call postInvalidate() from onStart in your base Fragment class
    • MavericksViewModel and BaseMvRxViewModel (from mavericks-rxjava2) no longer extends Jetpack ViewModel. However, viewModelScope and onCleared() still exist to match the existing API
    • The order of nested with and set states has changed slightly. It now matches the original intention. If you had code like: kotlin withState { // W1 withState { // W2 } setState { // S1 setState { // S2 setState { // S3 } } } } Previously, setState would only be prioritized at that nesting level so it would run: [W1, S1, W2, S2, S3] Now, it will run: [W1, S1, S2, S3, W2]
    • viewModelScope is now a property on MavericksViewModel and BaseMvRxViewModel (from mavericks-rxjava2), not the Jetpack extension function for ViewModel. Functionally, this is the same but the previous viewModelScope import will now be unused
    • ๐Ÿ— If you had been using any restricted internal mavericks library functions your build may break as they have been renamed (you shouldn't be doing this, but in case you are...)

    Other Changes

    • ๐Ÿ‘‰ Make MavericksViewModel extension functions protected (#488)
    • โž• Add MavericksViewModel.awaitState (#487) to access current ViewModel state via a suspend function
    • Mark all @RestrictTo APIs with @InternalMavericksApi (#480)
    • ๐Ÿคก Api additions to the mocking framework (#475) (#477)
    • โœ… Migrated CoroutinesStateStore to SharedFlow (#469)
    • ๐Ÿคก Launcher and mock speed optimizations (#468)
    • FragmentViewModelContext now allows for custom ViewModelStoreOwner and/or SavedStateRegistry that are different from the fragment ones in FragmentViewModelContext. (#443)
    • โž• Add mavericks-navigation artifact to support AndroidX Navigation destination ViewModels navGraphViewModel(R.id.my_graph) (#443)