Last active
August 8, 2016 04:28
-
-
Save frogermcs/94a92cc9894db97bfbd6221b344ee627 to your computer and use it in GitHub Desktop.
Async injection with Dagger 2 and RxJava
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
@Singleton | |
@Provides | |
Observable<HeavyExternalLibrary> provideHeavyExternalLibraryObservable(final Provider<HeavyExternalLibrary> heavyExternalLibraryProvider) { | |
return Observable.create(new Observable.OnSubscribe<HeavyExternalLibrary>() { | |
@Override | |
public void call(Subscriber<? super HeavyExternalLibrary> subscriber) { | |
subscriber.onNext(heavyExternalLibraryProvider.get()); | |
} | |
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment