Last active
January 21, 2016 04:15
-
-
Save maoruibin/fcd1836fd5237b56cb51 to your computer and use it in GitHub Desktop.
RxUtils
This file contains hidden or 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
/** | |
* make a operate change to observable | |
* @param func | |
* @param <T> | |
* @return | |
*/ | |
public static <T> Observable<T> makeObservable(final Callable<T> func) { | |
return Observable.create(new Observable.OnSubscribe<T>() { | |
@Override | |
public void call(Subscriber<? super T> subscriber) { | |
try { | |
subscriber.onNext(func.call()); | |
} catch (Exception e) { | |
subscriber.onError(e); | |
} | |
subscriber.onCompleted(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment