Created
March 24, 2015 23:36
-
-
Save kmdupr33/057612a1d383cc196c9a to your computer and use it in GitHub Desktop.
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
public class SafeObservable<T> extends Observable<T> { | |
/** | |
* Creates an Observable with a Function to execute when it is subscribed to. | |
* <p/> | |
* <em>Note:</em> Use {@link #create(rx.Observable.OnSubscribe)} to create an Observable, instead of this constructor, | |
* unless you specifically have a need for inheritance. | |
* | |
* @param f {@link rx.Observable.OnSubscribe} to be executed when {@link #subscribe(Subscriber)} is called | |
*/ | |
protected SafeObservable(OnSubscribe<T> f) { | |
super(f); | |
} | |
public Subscription safeSubscribe(Subscriber<T> subscriber) { | |
WeakSubscriberDecorator<T> weakSubscriberDecorator = new WeakSubscriberDecorator<>(subscriber); | |
return subscribe(weakSubscriberDecorator); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment