Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Releases: trbnb/MvvmBase

v3.0.3

19 Oct 11:41
Compare
Choose a tag to compare

Changes

  • update several dependencies

v3.0.2

18 Sep 13:28
Compare
Choose a tag to compare

Changes

  • move default constructor parameter value to secondary constructor of MvvmView implementations to ensure better compatibility with Dagger Hilt
  • don't crash in onBind & onUnbind if ViewModel is already destroyed

v3.0.1

27 Aug 20:02
Compare
Choose a tag to compare

Fix

  • Add notifyPropertyChanged(KProperty<*>) to databinding ViewModel again after it was lost due to lots of refactoring.

v3.0.0

18 Aug 18:15
Compare
Choose a tag to compare

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 Observables and Flows 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 {} and EventChannelOwner.lastEventAsState() to handle Events in @Composable functions
  • add observable<T>() delegate property with observeAsState()/observeAsMutableState()
  • add observableBindableAsState(), observeBindableAsMutableState()
  • add AndroidViewDataBinding()
  • add deprecated bindable() functions to help with migration fromde.trbnb.mvvmbase.databinding.ViewModel to de.trbnb.mvvmbase.ViewModel

Other changes

  • replace childrenBindable() with asChildren() extension function on BindableProperty.Provider<T>
  • onViewModelPropertyChanged has been deprecated and is not functional anymore (use KProperty0<T>.observeBindable {} instead)
  • replace MvvmView.observe with KProperty0<T>.observeBindable {}
  • SimpleCommand can be used outside of ViewModel (can be useful for default parameters of @Composable functions

v3.0.0 Alpha 2

10 Jul 18:41
Compare
Choose a tag to compare
v3.0.0 Alpha 2 Pre-release
Pre-release

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

13 May 11:02
Compare
Choose a tag to compare

Several dependency updates, including Kotlin 1.5.0.

2.1.0

24 Feb 22:17
Compare
Choose a tag to compare

Breaking changes

  • MvvmBindingController now implements HasDefaultViewModelProviderFactory and thus getDefaultViewModelProviderFactory() replaces defaultViewModelProviderFactory.

Features

  • Introduce KProperty0<T>.observe() in MvvmView as an alternative to onViewModelPropertyChanged().
  • Allow usage of non-threadsafe Lifecycle in ViewModel via MvvmBase.disableViewModelLifecycleThreadConstraints().
  • Allow configuration of default StateSaveOption either globally (MvvmBase.defaultStateSaveOption()) or ViewModel-specific (override StateSavingViewModel.defaultStateSaveOption).
  • Add MvvmView implementations for DialogFragment and BottomSheetDialogFragment.
  • Add viewModelProviderFactory { } convenience functions to override getDefaultViewModelProviderFactory() 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 unnecessary onUnbind() call won't crash anymore.
  • MvvmView.vmClass has been properly overriden for legacy MvvmView implementations.

2.0.1

27 Oct 17:53
Compare
Choose a tag to compare

Features

  • allow specifying DiffUtil.ItemCallback in BindingListAdapter

Changes

  • onViewModelLoaded() in MvvmView components is called after the binding is created and with that consistent in behaviour with MvvmActivity

2.0.0

18 Sep 20:05
Compare
Choose a tag to compare

Features

ViewModel

  • Add StateSavingViewModel and BaseStateSavingViewModel to support SavedStateHandle and automatic state saving in BindableProperties.
  • Add bindEvents function for nested ViewModels.
  • Add MvvmView.viewModelDelegate, can be overridden to make use of activityViewModels(), etc.
  • Add ViewModel.initTag() and ViewModel.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 and MvvmBindingController.

BindableProperty

  • Add bindable properties for unsigned primitive types.
  • Add MvvmBase.autoInit() function that uses de.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 to ViewModel.ruleCommand function to automatically call onEnabledChanged() when one of those IDs was used to call notifyPropertyChanged().
  • add Command.addEnabledListenerForView() & Command.clearEnabledListenersForViews() functions to manage View-related callbacks (see observeLifecycle & Command binding adapters).
  • Add ruleCommand() function with dependentField 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() and distinct().

Coroutines

  • Add Kotlin Coroutines module (de.trbnb.mvvmbase:mvvmbaseCoroutines) with FlowBindable<T>.

Conductor

  • Add MvvmBindingController.defaultViewModelProviderFactory property.

Lifecycle

  • Add Observable.addOnPropertyChangedCallback convenience function with LifecycleOwner parameter.

RecyclerView

  • Add BindingViewHolder that calls ViewModel.onUnbind() and ViewModel.onBind() appropriately.
  • Add BindingListAdapter together with a binding adapter function.

Changes

  • Java 8 is required.

ViewModel

  • autoDestroy() and bindEvents() are now available for a single ViewModel and collections of ViewModels.
  • Mark ViewModel.onDestroy() as protected and add ViewModel.destroy() to destroy ViewModels manually.
  • Rename List<VM>.onDestroy() to destroyAll and change the receiver type to Collection<VM>.

MvvmView

  • Remove viewModelProvider: Provider<VM> in favor of getDefaultViewModelProviderFactory().
  • Use ViewModelLazy as delegate property for MvvmView.viewModel in MvvmBindingActivity, MvvmBindingFragment and MvvmBindingController.
  • 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 BindablePropertys (including RxJava extensions).
  • distinct() checks for reference equality and doesn't use equals().

Commands

  • Make View.bindEnabled(Command) public.
  • Command now implements androidx.databinding.Observable.
  • Don't trigger enabled callbacks in SimpleCommand if isEnabled was reassigned the same value.

RxJava

  • Rename package de.trbnb.mvvmbase.rx to de.trbnb.mvvmbase.rxjava2.
  • autoDispose() now uses ViewModel.compositeDisposable to dispose instead of ViewModel.lifecycle.
  • add autoDispose(LifecycleOwner) function and deprecate autoDispose(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 for validate() was ignored.

2.0.0 RC 4

10 Aug 18:51
Compare
Choose a tag to compare
2.0.0 RC 4 Pre-release
Pre-release

Changes

  • Add covariance to BindingViewHolder type parameter
  • add BindingViewHolder.onBound() function to override for customization purposes