f2prateek/rx-preferences
f2prateek/rx-preferences has 1,519 GitHub stars and 129 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-06 07:19 UTC. Last push 2023-05-24.
Reactive SharedPreferences for Android
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalDEPRECATED
rx-preferences is deprecated. Please consider using a replacement, such as this. Thank you for using the library!
Rx Preferences
Reactive SharedPreferences for Android.
Usage
Create an RxSharedPreferences instance which wraps a SharedPreferences:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
RxSharedPreferences rxPreferences = RxSharedPreferences.create(preferences);
Hint: Keep a strong reference on your RxSharedPreferences instance for as long as you want to observe them to prevent listeners from being GCed.
Create individual Preference objects:
Preference<String> username = rxPreferences.getString("username");
Preference<Boolean> showWhatsNew = rxPreferences.getBoolean("show-whats-new", true);
Observe changes to individual preferences:
username.asObservable().subscribe(new Action1<String>() {
@Override public void call(String username) {
Log.d(TAG, "Username: " + username);
}
}
Subscribe preferences to streams to store values:
RxCompoundButton.checks(showWhatsNewView)
.subscribe(showWhatsNew.asConsumer());
(Note: RxCompoundButton is from RxBinding)
Download
implementation 'com.f2prateek.rx.preferences2:rx-preferences:2.0.1'
License
Copyright 2014 Prateek Srivastava
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Explore related projects
freeCodeCamp/freeCodeCamp
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
458,672 starsdonnemartin/system-design-primer
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
377,141 starsreact/react
The library for web and native user interfaces.
252,243 starsvuejs/vue
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
212,622 stars