Skip to content

Instantly share code, notes, and snippets.

@sockeqwe
Last active April 2, 2018 14:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sockeqwe/9ff1b611f8e41dea1930b73a67260ff5 to your computer and use it in GitHub Desktop.
Save sockeqwe/9ff1b611f8e41dea1930b73a67260ff5 to your computer and use it in GitHub Desktop.
class FooActivity extends MviActivity<...> {
@Inject FooPresenter
public void onCreate(Bundle bundle){
super.onCreate(bundle);
FooComponent component = DaggerFooComponent.builder()
.fooModule(new FooModule(bundle))
.build();
component.inject(this);
}
}
@Module
class FooModule {
private Bundle bundle;
public FooModule(Bundle bundle){
this.bundle = bundle;
}
@Provides
public FooPresenter provideFooPresenter(FooStateReducer stateReducer){
return FooPresenter(stateReducer);
}
@Provides
public FooStateReducer provideFooStateReducer(){
State initialState;
if (bunlde == null) {
initialState = new LoadingState();
} else {
initialState = bundle.getParcelable("StateKey");
}
return new FooStateReducer(initialState);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment