Skip to content

yzheka/ReactivePreferences

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8f7b697 · Feb 2, 2020

History

11 Commits
Feb 2, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020
Jan 30, 2020

Repository files navigation

ReactivePreferences

  • Create preferences:
class SomePreferences(...):RxPreferences(...) {
    val someInt by intPreference()
    val someString by stringPreference()
    val someEnum by serializablePreference<Test>(null,Test.TEST1)
    val someSerializable by serializablePreference<Data?>(null,null)
    ...
}
  • Use preferences
val preferences=SomePreferences(...)
preferences.someInt.value=0 // write value
val value=preferences.someInt.value // reat value
preferences.someInt.addOnChangeListener(...) // observe changes

//Helper extensions
val liveData = preferences.someInt.toLiveData()
va lobservable = preferences.someInt.toObservable()

Supported data types:

  • int
  • long
  • float
  • boolean
  • string
  • stringSet
  • serializable

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	...
	implementation "com.github.yzheka.ReactivePreferences:reactivepreferences:$latest_version"
	implementation "com.github.yzheka.ReactivePreferences:reactivepreferences-extensions:$latest_version" //for Rxjava2 and livedata support
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages