Preference { public Action1<? super T> asAction() { return new Action1<T>() { @Override public void call(T value) { SharedPreferences.Editor editor = preferences.edit(); proxy.set(key, value, editor); editor.apply(); } }; } Preference(SharedPreferences preferences, final String key, T defValue, Proxy<T> proxy, Observable<String> keyChanges); T asValue(); Observable<T> asObservable(); Action1<? super T> asAction();  }
@Test public void asAction() { Preference<String> preference = rxPreferences.getString("key1", "defValue"); Action1<? super String> action = preference.asAction(); action.call("value1"); assertThat(preferences.getString("key1", null)).isEqualTo("value1"); action.call("value2"); assertThat(preferences.getString("key1", null)).isEqualTo("value2"); }