Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Async injection with Dagger 2 and RxJava
@Singleton
@Provides
Observable<HeavyExternalLibrary> provideHeavyExternalLibraryObservable(final Lazy<HeavyExternalLibrary> heavyExternalLibraryLazy) {
return Observable.create(new Observable.OnSubscribe<HeavyExternalLibrary>() {
@Override
public void call(Subscriber<? super HeavyExternalLibrary> subscriber) {
subscriber.onNext(heavyExternalLibraryLazy.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
You can’t perform that action at this time.