Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

kafji/kpreferences

Repository files navigation

Kpreferences

This is work in progress.

Concept

Generate a class wrapper for SharedPreferences in Kotlin so we can use its properties to retrieve and set value in SharedPreferences.

interface MyPreferences {
  var userOnboardingDone: Boolean
}

By proxy class (reflection) like Retrofit.

val myPrefs = Kreferences(sharedPreferences).create(MyPreferences::class)
if (myPrefs.userOnboadingDone) {
  showUserOnboarding()
}

By annotation processing and codegen like Dagger and ButterKnife.

@Preferences interface MyPreferences {
  var userOnboardingDone: Boolean
}

val myPrefs = KreferencesMyPreferences(sharedPreferences)
if (myPrefs.userOnboadingDone) {
  showUserOnboarding()
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages