Helper Elements for MVVM (Model-View-ViewModel) Architecture Pattern.
Add below codes to your root build.gradle
file (not your module build.gradle file).
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
And add a dependency code to your module's build.gradle
file.
dependencies {
...
implementation 'com.github.arduia:mvvm-core:0.0.2'
}
Here is an example of implementing encapsulated MutableLiveData with infix method(set) for LiveData subscribers.
class MainViewModel: ViewModel(){
private val _isAvailable = BaseLiveData(initValue = true)
val isAvailable get() = _isAvailable.asLiveData()
fun setAvailableOff(){
_isAvailable set false
}
fun setAvailableOn(){
_isAvailable set true
}
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding true
}
dependencies {
def fragment_ktx_version = "1.2.5"
implementation "androidx.fragment:fragment-ktx:$fragment_ktx_version"
}
Inspired from Google's Android Architecture Samples(https://github.com/android/architecture-samples).
Copyright (C) 2020 Aung Ye Htet
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.