This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
Releases: trbnb/MvvmBase
Releases · trbnb/MvvmBase
v3.0.3
v3.0.2
v3.0.1
v3.0.0
based on Compose v1.0.0 stable
Changes since v2.x.x
The core module now contains Jetpack Compose features. Most of the previous databinding-compatible featureset was moved to the databinding module and the package-name of those APIs have moved from de.trbnb.mvvmbase
to de.trbnb.mvvmbase.databinding
. The RxJava and Coroutines modules have no Compose equivalent since Observable
s and Flow
s can be turned into State
already. Most of the changes will be in the following list but a bigger migration guide will not exist because I don't really have the time to write one.
Features
- add
EventChannelOwner
interface - add
EventChannelOwner.OnEvent {}
andEventChannelOwner.lastEventAsState()
to handle Events in@Composable
functions - add
observable<T>()
delegate property withobserveAsState()
/observeAsMutableState()
- add
observableBindableAsState()
,observeBindableAsMutableState()
- add
AndroidViewDataBinding()
- add deprecated
bindable()
functions to help with migration fromde.trbnb.mvvmbase.databinding.ViewModel
tode.trbnb.mvvmbase.ViewModel
Other changes
- replace
childrenBindable()
withasChildren()
extension function onBindableProperty.Provider<T>
onViewModelPropertyChanged
has been deprecated and is not functional anymore (useKProperty0<T>.observeBindable {}
instead)- replace
MvvmView.observe
withKProperty0<T>.observeBindable {}
SimpleCommand
can be used outside ofViewModel
(can be useful for default parameters of@Composable
functions
v3.0.0 Alpha 2
Changes since v2.x.x
- Core module now consists of Jetpack Compose functionality
- Data Binding functionality has been moved to "databinding" module and corresponding package name
de.trbnb.mvvmbase.databinding
onViewModelPropertyChanged
has been deprecated and is not functional anymore- add
EventChannelOwner
interface
2.1.1
2.1.0
Breaking changes
MvvmBindingController
now implementsHasDefaultViewModelProviderFactory
and thusgetDefaultViewModelProviderFactory()
replacesdefaultViewModelProviderFactory
.
Features
- Introduce
KProperty0<T>.observe()
inMvvmView
as an alternative toonViewModelPropertyChanged()
. - Allow usage of non-threadsafe Lifecycle in
ViewModel
viaMvvmBase.disableViewModelLifecycleThreadConstraints()
. - Allow configuration of default
StateSaveOption
either globally (MvvmBase.defaultStateSaveOption()
) or ViewModel-specific (overrideStateSavingViewModel.defaultStateSaveOption
). - Add
MvvmView
implementations forDialogFragment
andBottomSheetDialogFragment
. - Add
viewModelProviderFactory { }
convenience functions to overridegetDefaultViewModelProviderFactory()
more easily.
Changes
onEvent()
will always be called on the main thread.
Fixes
- Destroying a ViewModel in
MvvmView
implementations when using AndroidX Lifecycle version 2.3.0 due to unnecessaryonUnbind()
call won't crash anymore. MvvmView.vmClass
has been properly overriden for legacyMvvmView
implementations.
2.0.1
2.0.0
Features
ViewModel
- Add
StateSavingViewModel
andBaseStateSavingViewModel
to supportSavedStateHandle
and automatic state saving in BindableProperties. - Add
bindEvents
function for nested ViewModels. - Add
MvvmView.viewModelDelegate
, can be overridden to make use ofactivityViewModels()
, etc. - Add
ViewModel.initTag()
andViewModel.get()
to use tags via Jetpacks ViewModel tag functionality. - Add
ViewModel.childrenBindable()
function to create a BindableProperty for child-ViewModels that will destroy them when appropriate and bind their events.
MvvmView
- Add
MvvmView<VM, B>
as guideline for MVVM view components. - Add optional layout ID constructor paramter for
MvvmBindingActivity
,MvvmBindingFragment
andMvvmBindingController
.
BindableProperty
- Add bindable properties for unsigned primitive types.
- Add
MvvmBase.autoInit()
function that usesde.trbnb.mvvmbase.BR
file as BR file (will be extended if used in a project). afterSet
for BindableProperty-Providers now takes a lambda with two parameters (old & new value).
Commands
- Add
dependentFieldIds
parameter toViewModel.ruleCommand
function to automatically callonEnabledChanged()
when one of those IDs was used to callnotifyPropertyChanged()
. - add
Command.addEnabledListenerForView()
&Command.clearEnabledListenersForViews()
functions to manage View-related callbacks (seeobserveLifecycle
& Command binding adapters). - Add
ruleCommand()
function withdependentField
parameter to use property references instead of field IDs.
RxJava
- Add package for RxJava3 support:
de.trbnb.mvvmbase.rxjava3
. - Add
ViewModel.compositeDisposable
extension property. - Allow non-null default values for RxJava bindable property delegates.
- Add RxJava BindablePropertys support
beforeSet()
,validate()
anddistinct()
.
Coroutines
- Add Kotlin Coroutines module (
de.trbnb.mvvmbase:mvvmbaseCoroutines
) withFlowBindable<T>
.
Conductor
- Add
MvvmBindingController.defaultViewModelProviderFactory
property.
Lifecycle
- Add
Observable.addOnPropertyChangedCallback
convenience function withLifecycleOwner
parameter.
RecyclerView
- Add
BindingViewHolder
that callsViewModel.onUnbind()
andViewModel.onBind()
appropriately. - Add
BindingListAdapter
together with a binding adapter function.
Changes
- Java 8 is required.
ViewModel
autoDestroy()
andbindEvents()
are now available for a single ViewModel and collections of ViewModels.- Mark
ViewModel.onDestroy()
as protected and addViewModel.destroy()
to destroy ViewModels manually. - Rename
List<VM>.onDestroy()
todestroyAll
and change the receiver type toCollection<VM>
.
MvvmView
- Remove
viewModelProvider: Provider<VM>
in favor ofgetDefaultViewModelProviderFactory()
. - Use
ViewModelLazy
as delegate property forMvvmView.viewModel
inMvvmBindingActivity
,MvvmBindingFragment
andMvvmBindingController
. MvvmView.viewModel
now is not-nullable and must extend ViewModel from the Jetpack libraries.
BindableProperty
- Remove
@DependsOn
, the same can be achieved with@Bindable
. - Use property delegate provider syntax for all
BindableProperty
s (including RxJava extensions). distinct()
checks for reference equality and doesn't useequals()
.
Commands
- Make
View.bindEnabled(Command)
public. Command
now implementsandroidx.databinding.Observable
.- Don't trigger enabled callbacks in
SimpleCommand
ifisEnabled
was reassigned the same value.
RxJava
- Rename package
de.trbnb.mvvmbase.rx
tode.trbnb.mvvmbase.rxjava2
. autoDispose()
now usesViewModel.compositeDisposable
to dispose instead ofViewModel.lifecycle
.- add
autoDispose(LifecycleOwner)
function and deprecateautoDispose(Lifecycle)
.
Events
EventChannelImpl
no longer uses weak references for listeners.
Binding adapters
- All binding adapter function prefixes "
android:
" have been removed.
Proguard
- AAR file includes Proguard configuration file.
Fixes
ViewModel
ViewModel.onUnbind()
will now be called if ViewModel is about to be destroyed and is still bound.
BindableProperty
- Function that returns
null
and is used forvalidate()
was ignored.
2.0.0 RC 4
Changes
- Add covariance to
BindingViewHolder
type parameter - add
BindingViewHolder.onBound()
function to override for customization purposes