Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Async injection with Dagger 2 and RxJava
public class SplashActivity {
Observable<HeavyExternalLibrary> heavyExternalLibraryObservable;
//This will be injected asynchronously
HeavyExternalLibrary heavyExternalLibrary;
protected void onCreate(Bundle savedInstanceState) {
heavyExternalLibraryObservable.subscribe(new SimpleObserver<HeavyExternalLibrary>() {
public void onNext(HeavyExternalLibrary heavyExternalLibrary) {
//Our dependency will be available from this moment
SplashActivity.this.heavyExternalLibrary = heavyExternalLibrary;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment