{"id":20509272,"url":"https://github.com/futuremind/prefs-delegates","last_synced_at":"2025-09-25T08:31:50.503Z","repository":{"id":100256345,"uuid":"185182245","full_name":"FutureMind/prefs-delegates","owner":"FutureMind","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-04T07:15:52.000Z","size":207,"stargazers_count":4,"open_issues_count":8,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T20:29:30.583Z","etag":null,"topics":["android","kotlin","rxjava","rxjava2","sharedpreferences"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FutureMind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-06T11:20:29.000Z","updated_at":"2023-03-13T22:18:06.000Z","dependencies_parsed_at":"2023-05-13T05:45:40.372Z","dependency_job_id":null,"html_url":"https://github.com/FutureMind/prefs-delegates","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FutureMind%2Fprefs-delegates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FutureMind%2Fprefs-delegates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FutureMind%2Fprefs-delegates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FutureMind%2Fprefs-delegates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FutureMind","download_url":"https://codeload.github.com/FutureMind/prefs-delegates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234171614,"owners_count":18790677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kotlin","rxjava","rxjava2","sharedpreferences"],"created_at":"2024-11-15T20:23:42.142Z","updated_at":"2025-09-25T08:31:50.055Z","avatar_url":"https://github.com/FutureMind.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://jitpack.io/v/FutureMind/prefs-delegates.svg)](https://jitpack.io/#FutureMind/prefs-delegates)\n\n# Prefs delegates\nYet one more library leveraging kotlin magic for elegant shared prefs handling. With some extra rx sugar on top.\n\n## Features\n\n- Handles all primitive types that Shared Preferences do.\n- ...but adds hassle-free `enum` serialization.\n- ...and any arbitrary `Serializable` structure via `moshi` json serializer.\n- Takes care of proper handling of nullable and default values.\n- Provides `RxJava` observability.\n\n## Usage\n\n### Basic usage\n\nYou can use the delegates directly like you would use a regular variable:\n\n```kotlin\nvar someFlag by prefs.boolean(\"some_flag\", false)\n\ntextView.text = \"The flag is currently: $someFlag\" //loaded from shared preferences\n\nsomeFlag = true //saved to shared preferences\n```\n\n**The magic part is that every time you read or write the variable, it's loaded from shared prefs or saved to them.**\n\n### Nullability and default values\n\n```kotlin\nvar booleanImplicit by prefs.boolean(\"key1\", false)\nvar booleanExplicit: Boolean by prefs.boolean(\"key2\", false)\nvar booleanNullableImplicit by prefs.boolean(\"key3\")\nvar booleanNullableExplicit: Boolean? by prefs.boolean(\"key4\")\nvar booleanNullableExplicitDefault: Boolean? by prefs.boolean(\"key5\", false)\n```\n\n### Observable\n\n```kotlin\nval someObservableInt = prefs.observableInt(\"some_observable_int\")\n\nsomeObservableInt.observable().subscribe {\n    //will return the current value from shared prefs upon subscription\n    //and then while it's subscribed, every value subsequently written to it.\n}\n\n//for the observable to work you need to save via the same instance\nsomeObservableInt.save(21)\n```\n\n## Supported classes\n\n* `Boolean`\n* `Int`\n* `Long`\n* `Float`\n* `Double`\n* `String`\n* `StringSet`\n* `Enum` (saved as a string name of the enum)\n* and other classes that can be serialized to json via `moshi`\n\n\n**NOTE** Prefer [moshi-codegen](https://github.com/square/moshi#codegen) for json serialization. Reflection is much slower and deserializing large structures upon app startup may slow it down significantly. \n\n\n## Installation\n\nAdd it in your root build.gradle at the end of repositories:\n\n```groovy\nallprojects {\n    repositories {\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\nAdd the dependency with current JitPack version: [![](https://jitpack.io/v/FutureMind/prefs-delegates.svg)](https://jitpack.io/#FutureMind/prefs-delegates)\n\n```groovy\ndependencies {\n    implementation 'com.github.FutureMind:prefs-delegates:0.10.0'\n    \n    // or if you need only one of the library modules:\n    implementation 'com.github.FutureMind.prefs-delegates:preferencesdelegates:0.10.0'\n    implementation 'com.github.FutureMind.prefs-delegates:rxpreferencesdelegates:0.10.0'\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturemind%2Fprefs-delegates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturemind%2Fprefs-delegates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturemind%2Fprefs-delegates/lists"}