Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

Commit

Permalink
(impr) switch from void to firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
marcorei committed Dec 7, 2015
1 parent 6756d82 commit 5153c98
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public void call() {
* @param <T> Value type.
* @return Void Observable.
*/
public <T> Observable<Void> setValue(final Firebase reference, final T value) {
return Observable.create(new Observable.OnSubscribe<Void>() {
public <T> Observable<Firebase> setValue(final Firebase reference, final T value) {
return Observable.create(new Observable.OnSubscribe<Firebase>() {
@Override
public void call(final Subscriber<? super Void> subscriber) {
public void call(final Subscriber<? super Firebase> subscriber) {
reference.setValue(value, new ReactiveCompletionListener(subscriber));
// Can't remove complete listeners.
}
Expand All @@ -134,7 +134,7 @@ public void call(final Subscriber<? super Void> subscriber) {
* @param <T> Value type.
* @return Void Observable.
*/
public <T> Observable<Void> pushValue(Firebase reference, T value) {
public <T> Observable<Firebase> pushValue(Firebase reference, T value) {
return setValue(reference.push(), value);
}

Expand All @@ -143,10 +143,10 @@ public <T> Observable<Void> pushValue(Firebase reference, T value) {
* @param reference Target location.
* @return Void Observable.
*/
public Observable <Void> removeValue(final Firebase reference) {
return Observable.create(new Observable.OnSubscribe<Void>() {
public Observable <Firebase> removeValue(final Firebase reference) {
return Observable.create(new Observable.OnSubscribe<Firebase>() {
@Override
public void call(Subscriber<? super Void> subscriber) {
public void call(Subscriber<? super Firebase> subscriber) {
reference.removeValue(new ReactiveCompletionListener(subscriber));
// Can't remove complete listeners.
}
Expand Down Expand Up @@ -224,9 +224,9 @@ public void onCancelled(FirebaseError firebaseError) {
}

private class ReactiveCompletionListener implements Firebase.CompletionListener {
private Subscriber<? super Void> subscriber;
private Subscriber<? super Firebase> subscriber;

public ReactiveCompletionListener(Subscriber<? super Void> subscriber) {
public ReactiveCompletionListener(Subscriber<? super Firebase> subscriber) {
this.subscriber = subscriber;
}

Expand All @@ -236,6 +236,7 @@ public void onComplete(FirebaseError firebaseError, Firebase firebase) {
subscriber.onError(firebaseError.toException());
}
else {
subscriber.onNext(firebase);
subscriber.onCompleted();
}
}
Expand Down

0 comments on commit 5153c98

Please sign in to comment.