Skip to content

Helper Elements for MVVM (Model-View-ViewModel) Architecture. (Inspired form Google's Architecture Samples)

License

Notifications You must be signed in to change notification settings

arduia/mvvm-core

Repository files navigation

MVVM Core

Helper Elements for MVVM (Model-View-ViewModel) Architecture Pattern.

LICENSE API Version


Including in your project

Gradle

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'
	
	}

Usage

LiveData Encapsulation

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
    }
}

Dependencies(Optional)

    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildFeatures {
        viewBinding true
    }
    
    dependencies {
    
    def fragment_ktx_version = "1.2.5"
    implementation "androidx.fragment:fragment-ktx:$fragment_ktx_version"
    
    }

Credit

Inspired from Google's Android Architecture Samples(https://github.com/android/architecture-samples).

License

      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/>.

About

Helper Elements for MVVM (Model-View-ViewModel) Architecture. (Inspired form Google's Architecture Samples)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages