-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
lib/src/main/java/com/michaelflisar/rxbus/InternalRXBusUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.michaelflisar.rxbus; | ||
|
||
import com.michaelflisar.rxbus.interfaces.IRXBusIsResumedProvider; | ||
import com.michaelflisar.rxbus.rx.RXUtil; | ||
|
||
import rx.Observer; | ||
import rx.Subscriber; | ||
import rx.functions.Action1; | ||
|
||
/** | ||
* Created by flisar on 02.05.2016. | ||
*/ | ||
public class InternalRXBusUtil | ||
{ | ||
protected static <T> Action1<T> wrapQueueAction(Action1<T> action, IRXBusIsResumedProvider isResumedProvider) | ||
{ | ||
return new Action1<T>() | ||
{ | ||
@Override | ||
public void call(T t) | ||
{ | ||
if (RXUtil.safetyQueueCheck(t, isResumedProvider)) | ||
action.call(t); | ||
} | ||
}; | ||
} | ||
|
||
protected static <T> Observer<T> wrapObserver(Observer<T> observer, IRXBusIsResumedProvider isResumedProvider) | ||
{ | ||
return new Observer<T>() | ||
{ | ||
@Override | ||
public void onCompleted() | ||
{ | ||
observer.onCompleted(); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable e) | ||
{ | ||
observer.onError(e); | ||
} | ||
|
||
@Override | ||
public void onNext(T t) | ||
{ | ||
if (RXUtil.safetyQueueCheck(t, isResumedProvider)) | ||
observer.onNext(t); | ||
} | ||
}; | ||
} | ||
|
||
protected static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRXBusIsResumedProvider isResumedProvider) | ||
{ | ||
return new Subscriber<T>() | ||
{ | ||
@Override | ||
public void onCompleted() | ||
{ | ||
subscriber.onCompleted(); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable e) | ||
{ | ||
subscriber.onError(e); | ||
} | ||
|
||
@Override | ||
public void onNext(T t) | ||
{ | ||
if (RXUtil.safetyQueueCheck(t, isResumedProvider)) | ||
subscriber.onNext(t); | ||
} | ||
}; | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,5 @@ public static <T> boolean safetyQueueCheck(T event, IRXBusIsResumedProvider isRe | |
return false; | ||
} | ||
} | ||
|
||
} |