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
@Override | |
protected void setupActivityComponent() { | |
Observable.create(new Observable.OnSubscribe<Object>() { | |
@Override | |
public void call(Subscriber<? super Object> subscriber) { | |
final SplashActivityComponent splashActivityComponent = GithubClientApplication.get(SplashActivity.this) | |
.getAppComponent() | |
.plus(new SplashActivityModule(SplashActivity.this)); | |
splashActivityComponent.inject(SplashActivity.this); | |
subscriber.onCompleted(); | |
} | |
}) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new SimpleObserver<Object>() { | |
@Override | |
public void onCompleted() { | |
//Here is the moment when injection is done. | |
analyticsManager.logScreenView(getClass().getName()); | |
presenter.callAnyMethod(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment