Skip to content

Instantly share code, notes, and snippets.

@hkusu
Created July 8, 2017 02:24
Show Gist options
  • Save hkusu/aa56c1b3bbe39f170c5aefaf7ea66404 to your computer and use it in GitHub Desktop.
Save hkusu/aa56c1b3bbe39f170c5aefaf7ea66404 to your computer and use it in GitHub Desktop.
package io.github.hkusu.sample.android.lib.rx;
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
public class Event<T> {
private final Subject<T, T> subject = new SerializedSubject<>(PublishSubject.create());
public Observable<T> observable() {
return subject;
}
public void post(T t) {
subject.onNext(t);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment