{"id":18660392,"url":"https://github.com/patrick-doyle/android-rxstate","last_synced_at":"2026-02-25T16:03:17.473Z","repository":{"id":152359174,"uuid":"63282656","full_name":"patrick-doyle/android-rxstate","owner":"patrick-doyle","description":"Wrapper for managing android state restoration with a reactive functional interface","archived":false,"fork":false,"pushed_at":"2017-01-05T00:36:55.000Z","size":107,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-11T22:06:41.933Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrick-doyle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2016-07-13T22:03:59.000Z","updated_at":"2018-03-02T01:41:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bcd47eb-ce97-430d-b06d-4c06158f7dcb","html_url":"https://github.com/patrick-doyle/android-rxstate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/patrick-doyle/android-rxstate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2Fandroid-rxstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2Fandroid-rxstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2Fandroid-rxstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2Fandroid-rxstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrick-doyle","download_url":"https://codeload.github.com/patrick-doyle/android-rxstate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2Fandroid-rxstate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29829408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T15:41:19.027Z","status":"ssl_error","status_checked_at":"2026-02-25T15:40:47.150Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-07T07:43:33.422Z","updated_at":"2026-02-25T16:03:17.456Z","avatar_url":"https://github.com/patrick-doyle.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Android RxJava wrapper for updating and retrieving the saved state as any point in an activity/fragment or RxJava chain\n\n## RxSaveState\n\n#### Setup\nAdd `jcenter()` to the projects repositories build.gradle\n\n```groovy\n    repositories {\n        jcenter()\n    }\n```\nIn your module build.gradle file add the dependency\n\nCurrent Version is in the gradle.properties file [Here](gradle.properties) \n```groovy\n    dependencies {\n        compile \"com.twistedequations.rx:rx-savestate:{{current version}}\"\n    }\n```\nIf its giving an error about not finding a jar file use `com.twistedequations.rx:rx-savestate:{{current version}}@aar` instead\n\n## Usage\n\nTo obtain the previous state call the `RxSaveState.getSavedState(activity)` method, the observable returned emits the saved state as a bundle\ndownstream and completes. If there is no saved state then the observable just sends the onComplete event acting the same as Observable.empty()\n\n```java\n    RxSaveState.getSavedState(activity)\n    .map(new Func1\u003cBundle, CharSequence\u003e() {\n        @Override\n        public CharSequence call(Bundle bundle) {\n            return bundle.getCharSequence(STATE_KEY_TEXT);\n        }\n    })\n    .subscribe(new Action1\u003cCharSequence\u003e() {\n        @Override\n        public void call(CharSequence charSequence) {\n            Log.i(TAG, \"State restored with string \" + charSequence);\n            Toast.makeText(RxStateActivity.this, \"State restored for string \" + charSequence, Toast.LENGTH_SHORT).show();\n        }\n    });\n```\n\nTo save state you can use the `RxSaveState.updateSaveState()` function to update the state and add any new data. This can be called many times and any new values \nwill overwrite the previous one for a given key\n\n```java\n    RxView.clicks(button)\n    .map(new Func1\u003cVoid, CharSequence\u003e() {\n        @Override\n        public CharSequence call(Void aVoid) {\n            return editText.getText();\n        }\n    })\n    .doOnNext(new Action1\u003cCharSequence\u003e() {\n        @Override\n        public void call(final CharSequence charSequence) {\n            RxSaveState.updateSaveState(RxStateActivity.this,\n                    new BundleAction() {\n                        @Override\n                        public void call(Bundle bundle) {\n                            bundle.putCharSequence(STATE_KEY_TEXT, charSequence);\n                        }\n                    });\n        }\n    })\n    .subscribe(new Action1\u003cCharSequence\u003e() {\n        @Override\n        public void call(CharSequence charSequence) {\n            Log.i(TAG, \"State saved for string \"+ charSequence);\n            Toast.makeText(RxStateActivity.this, \"State saved for string \"+ charSequence, Toast.LENGTH_SHORT).show();\n        }\n    });\n```\n\nOne very useful application is combine these functions with other data sources to easily combine \nrestore state, disk cache and network loading\n\n```java\n    Observable savedStateObservable = RxSaveState.getSavedState(this) //save state and map to get the part of the state we need\n        .map(new Func1\u003cBundle, List\u003cItems\u003e\u003e() {\n            @Override\n            public List\u003cItems\u003e call(Bundle bundle) {\n                return bundle.getParceable(STATE_KEY);\n            }\n        })\n        .switdhIfEmpty(networkObservable()) //Fail over the network observable if the saved data obervable is empty\n        .doOnNext(new Action1\u003cList\u003cItems\u003e\u003e() {\n           @Override\n            public void call(final List\u003cItems\u003e data) {\n                RxSaveState.updateSaveState(RxStateActivity.this,\n                        new Action1\u003cBundle\u003e() {\n                            @Override\n                            public void call(Bundle bundle) {\n                                bundle.putParceable(STATE_KEY, data); //Update state with the lastest data\n                            }\n                        });\n            }.subscribe(new Action1\u003cList\u003cItems\u003e\u003e() {\n                 @Override\n                 public void call(List\u003cItems\u003e data) {\n                     view.setData(data);\n                 }\n            }\n```\n\n## Rx2SaveState\n\nSupport has been added for rxjava2. To use RxJava2 import the dependency\n```groovy\n    dependencies {\n        compile \"com.twistedequations.rx2:rx2-savestate:{{current version}}\"\n    }\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-doyle%2Fandroid-rxstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrick-doyle%2Fandroid-rxstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-doyle%2Fandroid-rxstate/lists"}