Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import rx.Observable;
import rx.subjects.PublishSubject;
public class Property<T> {
private T value;
private PublishSubject<T> property;
public Property() {
property = PublishSubject.create();
public T getValue() {
return value;
public void setValue(T value) {
this.value = value;
public Observable<T> observe() {
return property.asObservable();
import rx.Observable;
public class PropertySample {
public static void main(String[] args) {
Property<String> property = new Property<>();
property.setValue("New Value from Setter");
Observable.just("New Value from Observable")
System.out.println("Current val=" + property.getValue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment